Codectionary / Developer documentation / HTML

<head>

The <head> element contains metadata about the document — information that is not displayed directly on the page but is used by browsers, search engines, and other tools. This includes the page <title>, character encoding, linked stylesheets, scripts, and social media preview data. It must come before <body> and contains no visible content itself.

Syntax

<head>
  <title>Page Title</title>
  <meta charset="UTF-8">
</head>

Examples

Typical Head Contents

A well-formed head with the essentials.

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Codectionary - Learn to Code</title>
  <link rel="stylesheet" href="styles.css">
</head>

Head with a Script

Linking an external script from the head, deferred so it does not block rendering.

<head>
  <title>Codectionary - Learn to Code</title>
  <script src="app.js" defer></script>
</head>

Head with Favicon and Description

Additional common head metadata.

<head>
  <title>Codectionary - Learn to Code</title>
  <link rel="icon" href="/favicon.ico">
  <meta name="description" content="Thoughts on web development.">
</head>

Best practices

  • Always include a <title> and charset meta tag as early as possible in <head>
  • Use defer or async on <script> tags in the head so they do not block page rendering
  • Keep the head focused on metadata — no visible content belongs here
  • Charset and viewport meta tags are typically placed first for performance reasons

Browser compatibility

Support applies to the named feature, not every attribute or behaviour in this article. Versions refer to browsers, not operating systems.

<head>

Desktop

Chrome
Supported
From 1
Firefox
Supported
From 1
Safari
Supported
From 1
Edge
Supported
From 12
Opera
Supported
From 15

Mobile

Safari on iOS
Supported
From 1
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature · MDN reference

Support history and limitations

Chrome

  • From 1

Firefox

  • From 1

Safari

  • From 1

Edge

  • From 12

Opera

  • From 15

Safari on iOS

  • From 1

Chrome for Android

  • From 18

Firefox for Android

  • From 4

Samsung Internet

  • From 1.0

MDN BCD 8.1.5 · Dataset built 2026-10-08 · Mapping reviewed 2026-10-21. These dates are not individual browser-test or claim-verification dates. Unknown means the data does not establish support.

HTML Living Standard

Specifications & further reading