The <meta> tag is a header tag that is meant to do one of two things:
- provide supporting documentation about the Web page
- interact with the Web server
Most people are familiar with using meta tags to provide additional information about their pages to search engines. When used in this fashion, the meta tag provides name/value pairs that describe the Web page. It is then up to the search engine or other CGI or script to interpret them.
However, when used in the second fashion, the meta tag uses thehttp-equivattribute as the name for a name/value pair that the server will interpret. Elements that are stored in the http-equiv standard are meant to be included in the MIME document header that is passed to the browser before the document itself is passed.
Some common name/value pairs sent through the http-equiv meta tag:
- http-equiv="charset" content="iso-8859-1"
This defines the language used on the page
- http-equiv="expires" content="31 Dec 2000"
This defines the day the page will be out of date
- http-equiv="refresh" content="12"
The page will reload every 12 seconds (see below)
Redirecting your readers
One of the easiest things to do with most browsers is redirect readers to a new page. If you have a page with changing content, or the location has changed, you want to refresh the page either to the same location (the first example) or to another location (the second example).
For example, if you have a page that gets content from a database that is updated every 2 minutes, you would want the Web page to refresh every 2 minutes, to do this use a meta refresh tag:
meta http-equiv="Refresh" content="120"
- meta tells the browser that this is a special tag
- http-equiv says that it's an HTML MIME type
- Refresh tells the browser to reload the page
- content explains how long to wait between refreshes (in seconds)
Then, if you have a page that is gone, and you want your readers to be automatically transported to the new page, you just add one more thing to the content, a URL to go to:
meta http-equiv="Refresh" content="10;url=http://webdesign.about.com/"
The most important thing to remember is that you must separate the time and the URL with a semi-colon and not include any additional spaces or quotation marks.
Note: If you use this feature, and you set the refresh rate too low, your readers won't be able to use their "Back" button. Every time they hit the "Back" button, they will be redirected to the "refresh" page. This can be frustrating for people.