HTML Guide
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>
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.
A <p> element cannot be placed inside a <noscript> tag within the <head> section.
According to the HTML specification, the <head> element must only contain metadata, such as <title>, <meta>, <link>, <script>, and <style>. The <noscript> element is allowed in <head>, but it must only contain elements that are valid in head, not flow content like <p>. The <p> (paragraph) tag is flow content meant for the <body>. For fallback content in <head>, only metadata elements are allowed.
Incorrect example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
<noscript>
<p>JavaScript is disabled.</p>
</noscript>
</head>
<body>
</body>
</html>
Correct approaches:
-
Remove the <p> from <noscript> in <head>:
- If you must include fallback styles or links in case JavaScript is disabled, use only metadata tags.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
<noscript>
<link rel="stylesheet" href="no-js.css">
</noscript>
</head>
<body>
</body>
</html>
-
Place textual fallback content in the <body> instead:
- Moving the <noscript> block with flow content (such as <p>) to the body ensures validity.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<noscript>
<p>JavaScript is disabled.</p>
</noscript>
</body>
</html>
Remember: Do not use <p> (or any flow content) in <noscript> inside <head>. Use such content only in the body.
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>
And end tag has been found that does not match the current open element. Check the context to fix the start and end tags.
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.
An <a> tag can’t include other <a> tags inside. Most probable cause is an unclosed <a> tag, like in this example:
<a href="one.html">Page 1
<a href="two.html">Page 2</a>
A <button> tag can’t include other <button> tags inside. Most probable cause is an unclosed <button> tag, like in this example:
<button>Submit
<button>Cancel</button>
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>