Skip to main content
HTML Validation

Stray start tag “head”.

About This HTML Issue

The <head> element is the container for document metadata — things like the <title>, <meta> tags, <link> elements, and <script> references. According to the HTML specification, the <head> must be the first child element of <html> and must appear exactly once. When the browser’s parser encounters a second <head> tag, or a <head> tag after the <body> has already opened, it treats it as a “stray” start tag because it violates the expected document structure.

This issue commonly arises in several situations:

  • Duplicate <head> sections — often caused by copy-paste errors, template includes, or server-side rendering that injects a second <head> block.
  • <head> placed inside <body> — this can happen when restructuring a page or when a component or partial template incorrectly includes its own <head>.
  • Missing or misplaced closing tags — if you forget to close the <head> with </head> or accidentally close <html> early, subsequent tags may end up in unexpected positions.

This matters because browsers handle stray <head> tags inconsistently. Most modern browsers will silently ignore a second <head> and attempt to process its children as if they were part of <body>, which means your metadata (like <meta> charset declarations, stylesheets, or scripts) may not be recognized properly. This can lead to broken styling, encoding issues, missing SEO metadata, and unpredictable behavior across different browsers.

Examples

Duplicate <head> sections

A common mistake is having two <head> blocks in the same document:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <head>
    <meta name="description" content="My description">
  </head>
  <body>
    <p>Hello world</p>
  </body>
</html>

The second <head> triggers the stray start tag error. Merge everything into a single <head>:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
    <meta name="description" content="My description">
  </head>
  <body>
    <p>Hello world</p>
  </body>
</html>

<head> placed inside <body>

This often happens when a template partial or component includes its own <head>:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <head>
      <link rel="stylesheet" href="extra.css">
    </head>
    <p>Hello world</p>
  </body>
</html>

Move the metadata into the existing <head> section:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
    <link rel="stylesheet" href="extra.css">
  </head>
  <body>
    <p>Hello world</p>
  </body>
</html>

<head> appearing after <body>

Sometimes a <head> ends up after the closing </body> tag, particularly in dynamically assembled pages:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <p>Hello world</p>
  </body>
  <head>
    <meta charset="utf-8">
  </head>
</html>

Again, the fix is to consolidate everything into the single, correctly placed <head>:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My Page</title>
  </head>
  <body>
    <p>Hello world</p>
  </body>
</html>

Tip for template-based systems

If you use a templating engine, static site generator, or CMS, check that only your base layout defines the <head> element. Partials and components should inject content into the existing <head> using the templating system’s block or slot mechanism, rather than wrapping their metadata in a new <head> tag. Search the final rendered HTML output for all occurrences of <head to verify there is only one.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?

Ready to validate your sites?
Start your free trial today.