Home | SkillForge Blog | How to redirect a HTML page

How to redirect a HTML page

HTML5, Web Design

Sometimes in the web design world, you’ll need to redirect a page.  Maybe it’s because the page no longer exists, the page has been updated and moved, or it could be a page that you don’t want the user to be on for very long.  There are plenty of ways to do this.  You could use a bunch of different languages like PHP or JavaScript but there’s a way, in HTML, to accomplish this with the meta tag and here it is:

<meta http-equiv=refresh content=5;url=http://example.com/ />

Let’s break this down.  It looks just like a normal meta tag but it has an interesting attribute called http-equiv.  This allows the page to communicate back and forth with the server by simulating an HTTP response header.  The HTTP stands for Hyper-Text Transfer Protocol and equiv is short for equivalent.  The type of http-equiv header we are creating is going to be “refresh”  which means the page will be reloaded.

The content attribute has two values, the first one is how long it’s going to wait to run the page refresh and the second part is what page it will go to.  Let’s do another example, if I wanted the page that was loaded to go to Google after 10 seconds it would look like this:

<meta http-equiv=refresh content=“10;url=https://google.com/ />

Hope that tip helped and if you want to learn more about HTML, CSS, or JavaScript be sure to check out our HTML/CSS/JavaScript training for those languages and sign up.  Thanks and have an amazing day!