head element

If you don't know what an element is or how you must use it, I recommend you read the "HTML tags and attributes" tutorial that you can find in the HTML tutorials section.

Description

The head element is the container of a set of elements that provide metadata for the document. This metadata can specify the title (title element), character set, author, description or keywords of the document (meta element), a style sheet or relational information (link element) or embedded style declarations (style element), among others.

The presence of the title element is mandatory inside the head section of an HTML document. The only situation where it can be omitted is when the title is provided elsewhere (for example, by the parent of an iframe).

Examples

Below is an example of a simple document, where the head only contains the title. This example shows the minimum required contents for the head element when it isn't part of an iframe.

<!DOCTYPE html>
<html>
  <head>
    <title>The wall</title>
  </head>
  <body>
    <h1>Close the tunnel!</h1>
    <p>The night's watch will stand...</p>
  </body>
</html>

Now, another example expands the metadata provided for the document, using the elements meta, link and style.

<!DOCTYPE html>
<html>
  <head>
    <title>Winter is comming</title>
    <meta charset="utf-8">
    <meta name="author" content="Neddy">
    <link rel="stylesheet" type="text/css" href="styles.css">
    <style type="text/css">
      h1 {
        color: gray;
      }
    </style>
  </head>
  <body>
    <h1>Be prepared!</h1>
    <p>These are hard times for the realm...</p>
  </body>
</html>

Attributes

Specific attributes

profile

The location of a document containing metadata profiles. This information is used to establish a set of properties that may be used by the meta element and the link element.

This attribute has become obsolete in HTML5 and, therefore, its use is no longer valid. New profiles for the meta and link elements can be added in the HTML5 wiki (PragmaExtensions Wiki page and MetaExtensions Wiki page).

Example

<head profile="http://www.webprofiles.net/profiles/meta">

Global attributes

For information about global attributes refer to this list of global attributes in HTML5.

Events

Global events

For information about global events refer to this list of global events in HTML5.

X

Are you looking for a place to host your next website? I can help you with that!