[an error occurred while processing this directive]
|Location: > Support > META Tags Site Map|
|[an error occurred while processing this directive]|
With all the new HTML tags that are coming out, it's easy to overlook some of the greatest tools in our arsenal of HTML tricks. There are still a few HTML goodies lying around that'll help you keep your pages more up to date, make them easier to find, and even stop them from becoming framed. What's more, some of these tags have been with us since the first Web browsers were released.
META tags can be very useful for Web developers. They can be used to identify the creator of the page, what HTML specs the page follows, the keywords and description of the page, and the refresh parameter (which can be used to cause the page to reload itself, or to load another page). And these are just a few of the common uses!
First, there are two types of META tags: HTTP-EQUIV and META tags with a NAME attribute.
META HTTP-EQUIV tags are the equivalent of HTTP headers. To understand what headers are, you need to know a little about what actually goes on when you use your Web browser to request a document from a Web server. When you click on a link for a page, the Web server receives your browser's request via HTTP. Once the Web server has made sure that the page you've requested is indeed there, it generates an HTTP response. The initial data in that response is called the "HTTP header block." The header tells the Web browser information which may be useful for displaying this particular document
Back to META tags. Just like normal headers, META HTTP-EQUIV tags usually control or direct the actions of Web browsers, and are used to further refine the information which is provided by the actual headers. HTTP-EQUIV tags are designed to affect the Web browser in the same manner as normal headers. Certain Web servers may translate META HTTP-EQUIV tags into actual HTTP headers automatically so that the user's Web browser would simply see them as normal headers. Some Web servers, such as Apache and CERN httpd, use a separate text file which contains meta-data. A few Web server-generated headers, such as "Date," may not be overwritten by META tags, but most will work just fine with a standard Web server.
META tags with a NAME attribute are used for META types which do not correspond to normal HTTP headers. This is still a matter of disagreement among developers, as some search engine agents (worms and robots) interpret tags which contain the keyword attribute whether they are declared as "name" or "http-equiv," adding fuel to the fires of confusion.
On to more important issues, like how to actually implement META tags in your Web pages. If you've ever had readers tell you that they're seeing an old version of your page when you know that you've updated it, you may want to make sure that their browser isn't caching the Web pages. Using META tags, you can tell the browser not to cache files, and/or when to request a newer version of the page. In this article, we'll cover some of the META tags, their uses, and how to implement them.
This tells the browser the date and time when the document will be considered "expired." If a user is using Netscape Navigator, a request for a document whose time has "expired" will initiate a new network request for the document. An illegal Expires date such as "0" is interpreted by the browser as "immediately." Dates must be in the RFC850 format, (GMT format):
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
This is another way to control browser caching. To use this tag, the value must be "no-cache". When this is included in a document, it prevents Netscape Navigator from caching a page locally.
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
These two tags can be used as together as shown to keep your content current--but beware. Many users have reported that Microsoft's Internet Explorer refuses the META tag instructions, and caches the files anyway. So far, nobody has been able to supply a fix to this "bug." As of the release of MSIE 4.01, this problem still existed.
This tag specifies the time in seconds before the Web browser reloads the document automatically. Alternatively, it can specify a different URL for the browser to load.
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=/somenewdocument.html">
Be sure to remember to place quotation marks around the entire CONTENT attribute's value, or the page will not reload at all.
This is one method of setting a "cookie" in the user's Web browser. If you use an expiration date, the cookie is considered permanent and will be saved to disk (until it expires), otherwise it will be considered valid only for the current session and will be erased upon closing the Web browser.
<META HTTP-EQUIV="Set-Cookie" CONTENT="cookievalue=xxx;expires=Wednesday, 21-Oct-98 16:14:21 GMT; path=/">
This one specifies the "named window" of the current page, and can be used to prevent a page from appearing inside another framed page. Usually this means that the Web browser will force the page to go the top frameset.
<META HTTP-EQUIV="Window-target" CONTENT="_top">
Keyword and Description attributes
Chances are that if you manually code your Web pages, you're aware of the "keyword" and "description" attributes. These allow the search engines to easily index your page using the keywords you specifically tell it, along with a description of the site that you yourself get to write. Couldn't be simpler, right? You use the keywords attribute to tell the search engines which keywords to use, like this:
<META NAME="keywords" CONTENT="life, universe, mankind, plants, relationships, the meaning of life, science">
Incidentally, please don't try to "spike" the keywords by using the same word repeated over and over, as most search engines have refined their spiders to ignore such spam. Using the META description attribute, you add your own description for your page:
<META NAME="description" CONTENT="This page is about the meaning of life, the universe, mankind and plants.">
Make sure that you use several of your keywords in your description. While you are at it, you may want to include the same description enclosed in comment tags, just for the spiders that do not look at META tags. To do that, just use the regular comment tags, like this:
<!-- This page is about the meaning of life, the universe, mankind and plants. -->
Placement of META tags
META tags should always be placed in the head of the HTML document between the actual <HEAD> tags, before the BODY tag. This is very important with framed pages, as a lot of developers tend to forget to include them on individual framed pages. Remember, if you only use META tags on the frameset pages, you'll be missing a large number of potential hits. Here is an example of proper placement:
<HTML> <HEAD> <META NAME="keywords" CONTENT="sample, meta, tag, meta tags"> <META NAME="description" CONTENT="A short description of proper placement of meta tags"> <TITLE>Meta Placement</TITLE> </HEAD> <BODY> </BODY> </HTML>
Before leaving the topic of META tags, keep in mind that there are several legal issues that surround the use of these tags on your Web site. Danny Sullivan, editor of SearchEngineWatch, has put together a page detailing the lawsuits brought on revolving around META tags. At the present time there have already been at least five such suits, mainly focused on sites that utilized someone else's keywords within their META tags. The largest of these suits brought a settlement of $3 million dollars. Bottom line: use your own keywords, and definitely not words that someone else has a copyright on.[an error occurred while processing this directive]