What is the Meta Refresh Tag
The meta refresh tag or meta redirect is a tool for reloading and redirecting web pages. Remember that the meta refresh tag is easy to use and easy to use poorly. It uses HTML meta tags to change the current URL to a new one so the customer is taken automatically to a new web page.
How to Reload the Current Page with the Meta Refresh Tag
Place the following meta tag within the
HEAD of your HTML document. When used to refresh the current page, the syntax looks like this:
<meta http-equiv="refresh" content="600">
http-equiv="refresh"—This attribute tells the browser that this meta tag is sending an HTTP command rather than text content. The word
refresh is an HTTP header used by the web server. It tells the server that the page is going to be reloaded or sent somewhere else.
content="600"—This is the amount of time, in seconds, until the browser should reload the current page.
One of the most common uses of this version of the refresh tag is to reload a page that has dynamic content on it. For example: a stock ticker or weather map. Some people also use them to reload ads, but that can annoy your readers.
How to Redirect to a New Page with the Meta Refresh Tag
While being able to reload the current page is useful, it is not typically what people want from the meta refresh tag. To redirect to a new page, the syntax is nearly the same as reloading the current page:
<meta http-equiv="refresh" content="2;url=http://webdesign.about.com/">
But, as you can see above, the
content attribute is slightly different.
content="2;url=http://webdesign.about.com/"—The number is the time, in seconds, until the page should be redirected, just as before. Then, separated by a semi-colon (;) you write the URL of the new page to be loaded.
Be Careful. The most common error when writing a meta refresh tag to redirect to a new page is to add an extra quote mark in the middle. e.g.
content="2;url="http://newpage.com". If you set up a meta refresh tag and your page is not redirecting, check for that error first.
Drawbacks to Using Meta Refresh Tags
Meta refresh tags have some drawbacks:
- Meta refresh redirects have been used by spammers to fool search engines. So search engines remove those sites from their database. If you use a lot of meta refresh tags to redirect pages, the search engines may decide your site is spam and delete it from their index. It’s better to use a 301 Server Redirect instead.
- If the redirect happens quickly (less than 2-3 seconds), readers with older browsers can’t hit the “Back” button. This is a usability problem.
- If the redirect happens quickly and goes to a non-existant page, your readers may get stuck in a loop without seeing any content other than a 404 page. When this happens, most people simply give up and leave rather than trying to figure out where you were trying to take them.
- Refreshing the current page can confuse people. If they didn’t request the reload, some people can get concerned about security.
Did you find this article useful?
You can get more articles and information like this by subscribing to the site newsletter or RSS feed.