# Start tag “head” seen but an element of the same type was already open.

> Canonical HTML version: https://rocketvalidator.com/html-validation/start-tag-head-seen-but-an-element-of-the-same-type-was-already-open
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

An HTML document must contain exactly one `<head>` element, and it must be the first child of the `<html>` element. The `<head>` element holds metadata like the document title, character encoding, stylesheets, and scripts. When the validator encounters a second `<head>` start tag, it means the document structure is broken — the browser has to guess how to interpret the malformed markup, which can lead to unpredictable behavior.

This error matters for several reasons. First, metadata inside a malformed `<head>` may not be processed correctly, which can affect SEO, character encoding, and stylesheet loading. Second, browsers may silently "fix" the issue in different ways, leading to inconsistent rendering. Third, malformed document structure can confuse assistive technologies like screen readers.

The most common causes of this error are:

1. **A missing forward slash in the closing tag** — writing `<head>` instead of `</head>`. This is an easy typo to miss, especially in larger documents.
2. **Accidentally nesting a second `<head>` inside the first** — this can happen during copy-paste operations or when merging code from multiple sources.
3. **Templating errors** — when using a template engine, a partial or include might inject its own `<head>` tag into a document that already has one.

To fix the issue, search your HTML for every occurrence of `<head` and confirm that only one opening `<head>` tag exists and that the `<head>` section ends with a properly written `</head>` tag.

## Examples

### Missing forward slash on closing tag

This is the most common cause. The closing tag is written as `<head>` instead of `</head>`:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  <head>
  <body>
    <p>Hello world</p>
  </body>
</html>
```

**Fixed** — add the forward slash to properly close the `<head>`:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <p>Hello world</p>
  </body>
</html>
```

### Nested `<head>` elements

A second `<head>` block is incorrectly nested inside the first:

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

**Fixed** — remove the inner `<head>` and `</head>` tags, keeping the metadata in the single `<head>` element:

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

### Duplicate `<head>` from a template include

When working with template engines, an included partial might bring its own `<head>`, resulting in a duplicate:

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

**Fixed** — merge all metadata into a single `<head>` element:

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