HTML and CSS

The meta Element

Although it is not required in a document, the meta element performs so many different functions that it's a good idea to become familiar with it right away.

Document Encoding

Document encoding means setting the character set for your page, which is particularly important when writing documents in other languages. For many years, those of us writing in Latin characters (including English) used the ISO 8859-1 character set. The ISO sets and subsets cover a wide range of languages. But nowadays, we have UTF-8, a more universal format following a different standard than ISO values. UTF-8 can be helpful in a variety of browsers, but there are some limitations. If you are publishing in another language, such as Russian or Japanese, you'll want to have your document encoding set up under ISO rather than Unicode character sets.

Ideally, character encoding is set on the server and not in a meta element. However, you can set it using a meta element. See http://www.webstandards.org/learn/askw3c/dec2002.html.

The example shows a meta element that defines the UTF-8 format, suitable for documents in English as well as other languages, depending upon your browser support.

Example: Using meta to declare document encoding with Unicode

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Example shows a meta element for a document written in Russian, using the ISO method.

Example:Using meta to declare document encoding for Cyrillic, using ISO

<meta http-equiv="Content-Type" content="text/html; charset= iso-8859-5" />

Keywords, Description, and Authorship

The meta element can be used to describe keywords, describe the site, and define the author, too. This is extremely helpful for public search engines as well as for any search engine you might be running on your own site.

Keywords are single words and word combinations that would be used during a search. This assists people looking for specific topics to find the information you're providing.

Example:Using meta for keywords and keyword combinations

<meta name="keywords" content="html, xhtml, css, design, web design, development, web
development, perl, color, web color, blog, web log, weblog, books, computer books, articles,
tutorials, learn, author, instructor, instruction, instructing, training, education, consult,
 consultation, consultant, famous people page, famous people list, standards, web standards,
web standards project, wsp, wasp, digital web, digital web magazine, web techniques, web
techniques magazine, web review, webreview, webreview.com, wow, world" />

You'll notice that although I use the word web a great deal, it's in combination with other keywords. Most search engines will lock you out if you use multiple single keywords. This used to be a way of getting higher ranking, but no longer. Use keywords that make sense, or if you want to have multiple instances of a word, use it in a realistic combination.

Descriptions are typically 25 words or less and describe the purpose of your document.

Example:The meta element used for site or page description

<meta name="description" content="This Web site
shares my Web development work and personal thoughts." />

Short and to the point! Another use is to define the author of the document, as shown in exmaple below.

Example:Using meta to describe page authorship

<meta name="Author" content="The author name" />

Of course, this information is never displayed on your web page itself. Instead, as with all elements and attributes within the head portion of a document, this information is used by the browser and other resources such as search engines.

by BrainBellupdated
Advertisement: