HTML Meta Tags

Jakob Jenkov
Last update: 2014-06-15

HTML meta tags are HTML elements that provide meta information about your HTML document. HTML meta tags are thus not visible in the browser. The meta information is used by search engines to find out what your HTML page is about.

Meta tags must be located inside the head element of your HTML document. Here is how that looks:

<head>
  <meta name="keywords"    content="HTML, Text Formatting Elements">
  <meta name="description" content="Describes HTML's text formatting elements">
  <meta name="author"      content="Jakob Jenkov">
</head>

Inserting a meta tag is done using the meta element. The meta element is an empty element, meaning it has no element body - only attributes. Here is an example:

<meta name="keywords"    content="Dog, cat, pet, kitten, puppy">

A meta tag typically contains two attributes: name and content.

The name attribute contains the name of the meta information property you want the meta element to set a value for.

The content attribute sets the value for the meta information property named in the name attribute.

There are typically 3 meta information properties that you set for a page, using the meta tags. These are:

  • keywords
  • description
  • author

Setting values for these 3 meta information properties look like this:

<meta name="keywords"    content="HTML, Text Formatting Elements">
<meta name="description" content="Describes HTML's text formatting elements">
<meta name="author"      content="Jakob Jenkov">

The keywords property tell search engines what keywords are important in your HTML document. The keywords are separated by commas inside the content attribute. It is said that search engines do not look at this field anymore, since a lot of fraud has taken place in the past, with pages stuffing keywords into the keywords field which did not match the content of the HTML document.

The description property is normally used by search engines (or Google at least) when displaying your HTML document in search results. So is the value of the title element, by the way. First the title is displayed, then the description.

The author property tell who the author of the HTML document is.

All meta tags are optional, so it is up to you if you want to use them in your pages.

Jakob Jenkov

Featured Videos

Java Generics

Java ForkJoinPool

P2P Networks Introduction



















Close TOC
All Tutorial Trails
All Trails
Table of contents (TOC) for this tutorial trail
Trail TOC
Table of contents (TOC) for this tutorial
Page TOC
Previous tutorial in this tutorial trail
Previous
Next tutorial in this tutorial trail
Next