Skip to main content
HTML Validation

Stray start tag “html”.

About This HTML Issue

The <html> element serves as the root of an HTML document. According to the HTML specification, there can only be one root element, and it must contain exactly one <head> element followed by one <body> element. When the browser’s parser encounters a second <html> start tag, it doesn’t know what to do with it — the tag is considered “stray” because it appears in a context where it is not expected or allowed.

This error typically occurs in a few common scenarios:

  • Copy-paste mistakes — When copying HTML from another file, you may accidentally paste an entire document (including its <html> tag) inside an existing document.
  • Template or include errors — Server-side includes, template engines, or component-based frameworks may inject a full HTML document structure (with its own <html> tag) into a page that already has one.
  • Merging files incorrectly — Combining multiple HTML files without removing the structural tags from the inner files.
  • Accidental duplication — Simply having a duplicate <html> tag due to a typo or editing oversight.

A stray <html> tag signals a malformed document structure. Browsers will attempt to recover by ignoring the duplicate tag, but the intent behind the markup becomes ambiguous. This can lead to unpredictable rendering, broken styles, or scripts that fail to target elements correctly. It also harms accessibility, as screen readers and other assistive technologies rely on a well-formed document tree to interpret content.

To fix this issue, search your HTML source for all instances of <html and ensure only one exists — at the very top of the document, right after the <!DOCTYPE html> declaration. If you find a second one, remove it along with any corresponding duplicate </html>, <head>, </head>, <body>, and </body> tags that came with it, keeping only the actual content you need.

Examples

Incorrect: Duplicate <html> tag from pasted content

This example shows a full HTML document accidentally embedded inside another, which produces the stray start tag error:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <h1>Welcome</h1>

<!-- Accidentally pasted another full document -->

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title>Other Page</title>
      </head>
      <body>
        <p>This content was pasted from another file.</p>
      </body>
    </html>

  </body>
</html>

Correct: Single <html> element with merged content

Remove the duplicate document structure and keep only the content you need:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My Page</title>
  </head>
  <body>
    <h1>Welcome</h1>

<!-- Only the relevant content from the other file -->

    <p>This content was pasted from another file.</p>
  </body>
</html>

Incorrect: Accidental duplicate <html> tag

Sometimes the duplication is a simple typo:

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

Correct: Single <html> tag

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

Checking template-based projects

If you use a templating system (e.g., PHP includes, Jinja2, Handlebars, or similar), make sure your partials and includes contain only content fragments — not full document structures. For example, an included partial should look like this:

<!-- partial: sidebar.html — no <html>, <head>, or <body> tags -->

<aside>
  <nav>
    <ul>
      <li><a href="/">Home</a></li>
      <li><a href="/about">About</a></li>
    </ul>
  </nav>
</aside>

The key rule is simple: every HTML document must have exactly one <html> element. If the validator reports a stray start tag, trace it back to its source — whether that’s a copy-paste error, a template include, or a simple duplication — and remove it.

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.