This reference is built into PageRIJ — a live HTML, CSS & SVG authoring and learning environment.

HTML <head> element

The <head> element holds a document's metadata: information about the document and resources it uses. It is the first child element of <html>, followed by <body>.

An ordinary page has one <title> in its head to name the document. Other common contents include <meta> for metadata such as character encoding, <link> for related resources, <style> for CSS, and <script> for scripts. A <base> can supply a base URL for relative addresses. These elements affect the document without appearing as ordinary body content.

The permitted location depends on the particular element and its attributes. For example, <meta> with itemprop can occur in body content, and some <link> relationships are also allowed there. Scripts and <template> elements can occur in either the head or body. A <noscript> in the head has more restricted contents than one in the body.

For an external classic script in the head, defer allows downloading during parsing and execution after parsing finishes. With async, execution happens when the script is ready and may occur before parsing finishes. These attributes therefore provide different execution timing; an async script cannot assume that later body elements already exist.

The example below contains only a character encoding declaration and a title in its head. The heading displayed within the document belongs in the body.

Attributes: GLOBALS.

Typical layout:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Welcome</title>
</head>
<body>
  <h1>Welcome</h1>
</body>
</html>
Visual representation:

None within the page body.