About This HTML Issue
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:
-
A missing forward slash in the closing tag — writing
<head>instead of</head>. This is an easy typo to miss, especially in larger documents. -
Accidentally nesting a second
<head>inside the first — this can happen during copy-paste operations or when merging code from multiple sources. -
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>:
<!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>:
<!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:
<!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:
<!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:
<!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:
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
<link rel="stylesheet" href="extra.css">
</head>
<body>
<p>Hello world</p>
</body>
</html>
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.
Learn more: