HTML <head> Element

The HTML <head> element contains metadata and resources that provide information about an HTML document. It commonly contains elements that define the page title, character encoding, viewport settings, stylesheets, scripts, and other information used by browsers and search engines.

Syntax

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Page Title</title>
  </head>
  <body>

    Page content

  </body>
</html>

The <head> element is placed inside the <html> element and before the <body> element. It requires both an opening and closing tag.

Attributes

The <head> element supports the global HTML attributes. It does not have any element-specific attributes.

Example

This example shows a basic HTML document with common elements placed inside the <head>. The page title appears in the browser tab, while the metadata and stylesheet provide information and resources used by the browser.

Play in Editor

Usage Notes

An HTML document contains one <head> element. It appears after the opening <html> tag and before the <body> element.

The <head> contains metadata and supporting resources rather than the main content displayed on the page. Visible page content normally belongs inside the <body> element.

Common elements used inside the <head> include <title>, <meta>, <link>, <style>, <base>, and <script>.

The <title> element provides the document title used by browsers and is required in most HTML documents. Metadata such as the character encoding and viewport configuration is commonly provided with <meta> elements.

Stylesheets can be connected to the document with the <link> element, while document-specific CSS can be placed in a <style> element. Scripts may also appear in the <head> when appropriate.

Accessibility

The <head> element is not displayed as page content, but information contained within it can affect accessibility. A clear and descriptive <title> helps users identify a page in browser tabs, bookmarks, history, and assistive technology.

Correct character encoding and viewport information also help browsers present the document reliably across different devices and user configurations.

Browser Support

Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.

For detailed browser compatibility information, see Can I Use: HTML <head> Element .

<html> - Represents the root element that contains the entire HTML document.

<title> - Defines the title of the HTML document.

<meta> - Provides metadata about the document that cannot be represented by other metadata elements.

<link> - Defines a relationship between the current document and an external resource, such as a stylesheet.

<style> - Contains CSS rules that apply to the document.

<body> - Contains the main content displayed as part of the web page.

Specifications

HTML Living Standard: The <head> Element