HTML Guide
All HTML documents must start with a <!DOCTYPE>
(Document Type Declaration), that informs browsers about the type and version of HTML used to build the document. In HTML5, this is simply <!DOCTYPE html>
and must appear at the start of the document.
Here is an example of a minimal HTML document, including the Document Type Declaration at its start:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
Related W3C validator issues
Rocket Validator checks HTML on your sites using the latest version of W3C Validator Nu HTML Checker, which is intended for HTML5 documents.
The page scanned is using an “almost standards mode” doctype, instead of the expected <!DOCTYPE html>. While the almost standards mode was used in the transition to HTML5, you should consider moving to the HTML5 standard.
HTML documents are expected to start with a first line containing the Document Type Declaration, that defines the HTML version used. Since HTML5, it’s just <!DOCTYPE html>, which must appear before the start <html> tag.
Here’s an example of a minimal HTML5 document:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
A missing or incorrectly placed <!DOCTYPE html> declaration at the very start of your HTML document causes this error.
The <!DOCTYPE html> declaration must be the very first thing in your HTML file, before any HTML code. This declaration tells the browser to use standards mode, ensuring reliable rendering. Without it, browsers may behave unpredictably or trigger quirks mode, and validators will issue an error.
Correct Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Valid HTML Document</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Incorrect Example (doctype missing):
<html lang="en">
<head>
<title>Invalid HTML Document</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Incorrect Example (doctype not at the very start):
Some misplaced text.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Invalid Placement</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Always ensure <!DOCTYPE html> is the first line.
Rocket Validator checks HTML on your sites using the latest version of W3C Validator Nu HTML Checker, which is intended for HTML5 documents.
The page scanned is using an obsolete doctype, instead of the expected <!DOCTYPE html>.
The <!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN"> doctype triggers quirks mode in modern browsers and is not compliant with HTML5 standards.
The HTML5 specification requires the use of a simple doctype declaration, which ensures standards mode rendering. The correct doctype is <!DOCTYPE html>, which must appear at the very top of every HTML5 document. Legacy doctypes like HTML 4.0 Transitional are obsolete for modern web development and can cause inconsistent browser behavior.
Example of correct usage:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Valid HTML5 Doctype Example</title>
</head>
<body>
<p>Your content here.</p>
</body>
</html>
Replace any legacy or malformed doctype with the above declaration to conform to current HTML standards.
HTML documents are expected to start with a first line containing the Document Type Declaration, that defines the HTML version used. Since HTML5, it’s just <!DOCTYPE html>, which must appear before the start <html> tag.
Here’s an example of a minimal HTML5 document:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
An end tag for X has been found that does not correspond to a previous open tag. This usually happens when you close the same tag twice, for example:
<ul>
<li>item</li>
</ul>
</ul>
A <div> tag appears where the HTML structure does not expect it, often due to incorrect nesting or missing closing tags.
HTML elements must be properly nested and closed according to the specifications outlined by the HTML standard. A stray start tag usually occurs when a block-level element like <div> is used in a context where only phrasing (inline) content is permitted, or if required closing tags (such as </li>, </tr>, or </td>) are missing, causing the parser to be out of sync.
Incorrect Example: div after closing the html tag
<!DOCTYPE html>
<html lang="">
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
<div>
some extra content
</div>
In the above, the <div> at the bottom is not valid because it appears after closing the html tag.
Always close elements properly and place block-level elements like <div> only inside appropriate containers. If your issue occurs elsewhere, look for missing closing tags or incorrect placement of the <div> relative to tables, lists, or other structural elements.
A <head> start tag has been found in an unexpected place in the document structure. Check that the <head> section appears before the <body> section, and that is not duplicated.
The <head> section of an HTML document is the container of metadata about the document, and must appear before the <body> section. A common cause of this issue is duplicated <head> sections.
Here is an example of a minimal HTML document structure:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p></p>
</body>
</html>
A stray start tag <html> has been found in the document. As this tag defines the start of the whole HTML document, it should appear only once.