HTML Guides
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
All HTML documents must use UTF-8 character encoding. The shift_jis encoding is a legacy Japanese encoding that is no longer valid in modern HTML.
The HTML specification requires UTF-8 as the only permitted character encoding for HTML documents. This rule applies regardless of the document's language or the characters it contains. Legacy encodings like shift_jis, euc-jp, iso-8859-1, and others are not allowed.
To fix this, two things need to happen. First, the <meta> charset declaration must specify UTF-8. Second, the file itself must actually be saved with UTF-8 encoding. Declaring UTF-8 in the markup while the file is saved as Shift_JIS will cause garbled text (mojibake). Most modern text editors and IDEs (VS Code, Sublime Text, Notepad++) can convert a file's encoding through a "Save with Encoding" or "Reopen with Encoding" option.
If a server sends a Content-Type header with charset=shift_jis, that header also needs to be updated to charset=utf-8. The HTTP header takes precedence over the <meta> tag, so fixing only the HTML is not enough if the server overrides it.
HTML examples
Before (invalid)
<!doctype html>
<html lang="ja">
<head>
<meta charset="shift_jis">
<title>Example</title>
</head>
<body>
<p>日本語のテキスト</p>
</body>
</html>
After (valid)
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Example</title>
</head>
<body>
<p>日本語のテキスト</p>
</body>
</html>
Make sure the file is also saved as UTF-8 in your text editor. In VS Code, click the encoding label in the bottom status bar and select "Save with Encoding" then "UTF-8".
The HTML living standard mandates UTF-8 as the only permitted character encoding for HTML documents. Legacy encodings like windows-1252, iso-8859-1, shift_jis, and others were common in older web pages, but they support only a limited subset of characters. UTF-8, on the other hand, can represent every character in the Unicode standard, making it universally compatible across languages and scripts.
This issue typically arises from one or more of these causes:
- Missing or incorrect
<meta charset>declaration — Your document either lacks a charset declaration or explicitly declares a legacy encoding like<meta charset="windows-1252">. - File not saved as UTF-8 — Even with the correct
<meta>tag, if your text editor saves the file in a different encoding, characters may become garbled (mojibake). - Server sends a conflicting
Content-Typeheader — The HTTPContent-Typeheader can override the in-document charset declaration. If your server sendsContent-Type: text/html; charset=windows-1252, the browser will use that encoding regardless of what the<meta>tag says.
Why This Matters
- Standards compliance: The WHATWG HTML living standard explicitly states that documents must be encoded in UTF-8. Using a legacy encoding makes your document non-conforming.
- Internationalization: Legacy encodings like
windows-1252only support a limited set of Western European characters. If your content ever includes characters outside that range—emoji, CJK characters, Cyrillic, Arabic, or even certain punctuation—they won't render correctly. - Security: Mixed or ambiguous encodings can lead to security vulnerabilities, including certain types of cross-site scripting (XSS) attacks that exploit encoding mismatches.
- Consistency: When the declared encoding doesn't match the actual file encoding, browsers may misinterpret characters, leading to garbled text that's difficult to debug.
How to Fix It
Step 1: Declare UTF-8 in your HTML
Add a <meta charset="utf-8"> tag as the first element inside <head>. It must appear within the first 1024 bytes of the document so browsers can detect it early.
Step 2: Save the file as UTF-8
In most modern text editors and IDEs, you can set the file encoding:
- VS Code: Click the encoding label in the bottom status bar and select "Save with Encoding" → "UTF-8".
- Sublime Text: Go to File → Save with Encoding → UTF-8.
- Notepad++: Go to Encoding → Convert to UTF-8.
If your file already contains characters encoded in windows-1252, simply changing the declaration without re-encoding the file will cause those characters to display incorrectly. You need to convert the file's actual encoding.
Step 3: Check your server configuration
If your server sends a charset parameter in the Content-Type HTTP header, make sure it specifies UTF-8. For example, in Apache you can add this to your .htaccess file:
AddDefaultCharset UTF-8
In Nginx, you can set it in your server block:
charset utf-8;
Examples
Incorrect: Legacy encoding declared
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="windows-1252">
<title>My Page</title>
</head>
<body>
<p>Hello world</p>
</body>
</html>
This triggers the error because windows-1252 is a legacy encoding.
Incorrect: Using the long-form http-equiv with a legacy encoding
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
This older syntax also triggers the error when it specifies a non-UTF-8 encoding.
Correct: UTF-8 declared properly
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<p>Hello world</p>
</body>
</html>
The <meta charset="utf-8"> tag appears as the first child of <head>, and the file itself should be saved with UTF-8 encoding.
Correct: Using http-equiv with UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
While the shorter <meta charset="utf-8"> form is preferred, this longer syntax is also valid as long as it specifies UTF-8.
When a browser or validator reads your HTML file, it interprets the raw bytes according to a character encoding — most commonly UTF-8. Each encoding has rules about which byte sequences are valid. For example, in UTF-8, bytes above 0x7F must follow specific multi-byte patterns. If the validator encounters a byte or sequence of bytes that violates these rules, it reports a "malformed byte sequence" error because it literally cannot decode the bytes into meaningful characters.
This problem commonly arises in a few scenarios:
- Encoding mismatch: Your file is saved as Windows-1252 (or Latin-1, ISO-8859-1) but the document declares UTF-8, or vice versa. Characters like curly quotes (
""), em dashes (—), or accented letters (é,ñ) are encoded differently across these encodings, producing invalid byte sequences when interpreted under the wrong one. - Copy-pasting from word processors: Content copied from Microsoft Word or similar applications often includes "smart quotes" and special characters encoded in Windows-1252, which can produce malformed bytes in a UTF-8 file.
- File corruption: The file was partially corrupted during transfer (e.g., FTP in the wrong mode) or by a tool that modified it without respecting its encoding.
- Mixed encodings: Parts of the file were written or appended using different encodings, resulting in some sections containing invalid byte sequences.
This is a serious problem because browsers may display garbled text (mojibake), skip characters entirely, or substitute replacement characters (�). It also breaks accessibility tools like screen readers, which may mispronounce or skip corrupted text. Search engines may index garbled content, harming your SEO.
How to Fix It
- Declare UTF-8 encoding in your HTML with
<meta charset="utf-8">as the first element inside<head>. - Save your file as UTF-8 in your text editor. Most editors have an option like "Save with Encoding" or "File Encoding" in the status bar or save dialog. Choose "UTF-8" or "UTF-8 without BOM."
- Re-encode the file if it was originally saved in a different encoding. Tools like
iconvon the command line can convert between encodings:iconv -f WINDOWS-1252 -t UTF-8 input.html -o output.html
- Replace problematic characters by re-typing them or using HTML character references if needed.
- Check your server configuration. If your server sends a
Content-Typeheader with a charset that conflicts with the file's actual encoding (e.g.,Content-Type: text/html; charset=iso-8859-1for a UTF-8 file), the validator will use the HTTP header's encoding, causing mismatches.
Examples
Incorrect — Encoding mismatch
A file saved in Windows-1252 but declaring UTF-8. The byte 0xE9 represents é in Windows-1252 but is an invalid lone byte in UTF-8, triggering the malformed byte sequence error.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<!-- If the file is saved as Windows-1252, the é below is byte 0xE9, -->
<!-- which is not a valid UTF-8 sequence -->
<p>Resumé</p>
</body>
</html>
Correct — File properly saved as UTF-8
The same document, but the file is actually saved in UTF-8 encoding. The character é is stored as the two-byte sequence 0xC3 0xA9, which is valid UTF-8.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<p>Resumé</p>
</body>
</html>
Alternative — Using character references
If you can't resolve the encoding issue immediately, you can use HTML character references to avoid non-ASCII bytes entirely:
<p>Resumé</p>
Or using the named reference:
<p>Resumé</p>
Both render as "Resumé" regardless of file encoding, though this is a workaround — properly saving the file as UTF-8 is the preferred long-term solution.
According to the HTML specification, <meta> elements are metadata content and must appear within the <head> element. When a <meta> tag appears between </head> and <body>, browsers have to error-correct by either ignoring the element or silently relocating it into the head. This can lead to unpredictable behavior — for instance, a <meta charset="utf-8"> tag in the wrong position might not be processed in time, causing character encoding issues. Similarly, a misplaced <meta name="viewport"> could fail to apply on some browsers, breaking your responsive layout.
There are several common causes for this error:
- A
<meta>tag accidentally placed after</head>— perhaps added hastily or through a copy-paste error. - A duplicate
<head>section — if a second<head>block appears in the document, the browser closes the first one implicitly, leaving orphaned<meta>elements in limbo. - An unclosed element inside
<head>— a tag like an unclosed<link>or<script>can confuse the parser, causing it to implicitly close</head>earlier than expected, which pushes subsequent<meta>tags outside the head. - Template or CMS injection — content management systems or templating engines sometimes inject
<meta>tags at incorrect positions in the document.
To fix the issue, inspect your HTML source and ensure every <meta> element is inside a single, properly structured <head> section. Also verify that no elements within <head> are unclosed or malformed, as this can cause the parser to end the head section prematurely.
Examples
Incorrect — <meta> between </head> and <body>
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
<meta charset="utf-8">
</head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<body>
<p>Hello, world!</p>
</body>
</html>
The <meta name="viewport"> tag is outside <head>, triggering the validation error.
Incorrect — duplicate <head> sections
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
<meta charset="utf-8">
</head>
<head>
<meta name="description" content="A sample page">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
The second <head> block is invalid. The browser ignores it, leaving the <meta name="description"> element stranded between </head> and <body>.
Incorrect — unclosed element forces early head closure
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<div>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
The <div> is not valid inside <head>, so the parser implicitly closes the head section when it encounters it. The subsequent <meta> tag ends up outside <head>.
Correct — all <meta> elements inside <head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A sample page">
<title>My Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
All <meta> elements are properly contained within a single <head> section. Note that <meta charset="utf-8"> should ideally be the very first element in <head> so the browser knows the encoding before processing any other content.
The HTML specification defines a strict content model for tables. A <table> element can only contain <caption>, <colgroup>, <thead>, <tbody>, <tfoot>, and <tr> as direct children. A <tr> element can only contain <td> and <th> elements. When text or inline elements like <span>, <a>, or <strong> appear directly inside any of these table-structural elements, they violate the content model and trigger this validation error.
This matters for several reasons. Browsers handle misplaced table content inconsistently — some will silently move the text before the table, others may discard it, and some may attempt to create anonymous table cells. This leads to unpredictable layouts across browsers and devices. Screen readers rely on correct table structure to navigate cells and announce row/column relationships, so misplaced content can confuse assistive technology users. Additionally, any text placed directly inside a <tr> but outside a cell is technically not part of any row/column structure, making it semantically meaningless in the table context.
Common causes of this error include:
- Accidentally placing text between
<tr>and<td>tags - Placing a heading or paragraph directly inside a
<table>(use<caption>instead for table titles) - Using non-breaking spaces (
) or other characters directly inside<table>or<tr>for spacing - Incorrectly nesting non-table elements like
<div>,<p>, or<form>as direct children of<table>or<tr>
Examples
Text directly inside a table row
<!-- ❌ Wrong: text is a direct child of <tr> -->
<table>
<tr>
Hello World
<td>First Cell</td>
<td>Second Cell</td>
</tr>
</table>
<!-- ✅ Fixed: text is wrapped in a <td> -->
<table>
<tr>
<td>Hello World</td>
<td>First Cell</td>
<td>Second Cell</td>
</tr>
</table>
Text directly inside a table element
<!-- ❌ Wrong: heading and spacing text placed directly in <table> -->
<table>
Monthly Sales Report
<tr>
<th>Month</th>
<th>Revenue</th>
</tr>
</table>
<!-- ✅ Fixed: use <caption> for table titles -->
<table>
<caption>Monthly Sales Report</caption>
<tr>
<th>Month</th>
<th>Revenue</th>
</tr>
</table>
Non-breaking spaces used for spacing
<!-- ❌ Wrong: directly inside <tr> -->
<table>
<tr>
<td>Data</td>
</tr>
</table>
<!-- ✅ Fixed: use CSS for spacing, or place content in a cell -->
<table>
<tr>
<td>Data</td>
</tr>
</table>
Inline elements directly inside a table
<!-- ❌ Wrong: <a> tag directly inside <table> -->
<table>
<a href="/details">View details</a>
<tr>
<td>Item 1</td>
<td>$10.00</td>
</tr>
</table>
<!-- ✅ Fixed: move the link into a cell or outside the table -->
<table>
<tr>
<td>Item 1</td>
<td>$10.00</td>
<td><a href="/details">View details</a></td>
</tr>
</table>
Content between table sections
<!-- ❌ Wrong: text between <thead> and <tbody> -->
<table>
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
No results found
<tbody>
<tr>
<td>—</td>
</tr>
</tbody>
</table>
<!-- ✅ Fixed: place the message inside a cell -->
<table>
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>No results found</td>
</tr>
</tbody>
</table>
A numeric character reference starts with &# but has no digits after it, so the parser can't turn it into a character.
Numeric character references come in two forms: &# followed by a decimal number, such as ©, or &#x followed by a hexadecimal number, such as ©. Both end with a semicolon. When the parser reads &# or &#x and the next character isn't a digit, it reports this error and keeps those characters as plain text, so &#; shows up on the page exactly as typed.
The quoted part of the message is the text that comes before &# in the same attribute value. For a reference in text content there is no preceding text, so the quotes are empty. Two common causes are a template that builds a reference from an empty variable, such as an icon font code point, and a literal &# in text or in a URL that was never escaped.
To fix it, put the code point of the character you want between &# and the semicolon, or use a named reference like ©. If you meant to show the characters &# on the page, escape the ampersand as &#.
Invalid example
<p><span class="icon" aria-hidden="true">&#x;</span> Cart</p>
<p>Type &# and a number to insert a character by its code point.</p>
Valid example
<p><span class="icon" aria-hidden="true">🛒</span> Cart</p>
<p>Type &# and a number to insert a character by its code point.</p>
The HTML specification defines <p> as an element that can only contain phrasing content — essentially inline elements like <span>, <a>, <strong>, <em>, and text. When the parser encounters a block-level element (such as <div>, <ul>, <ol>, <table>, <blockquote>, or another <p>) inside a <p>, it automatically closes the <p> element before the block-level element. This implicit closure means that a </p> tag appearing after the block-level element has no matching open <p> to close.
Understanding this behavior is important because it can lead to unexpected DOM structures. Browsers will still render the page, but the actual DOM tree may differ from what you intended, potentially affecting CSS styling and JavaScript DOM manipulation. It also signals structural problems in your markup that can hurt accessibility, since assistive technologies rely on a well-formed document tree.
There are three common causes of this error:
- Duplicate closing tags — A simple typo where
</p>appears twice. - Block-level elements inside
<p>— Nesting a<div>,<ul>,<table>, or similar element inside a paragraph causes the browser to implicitly close the<p>before the block element, leaving the explicit</p>orphaned. - Mismatched or misordered tags — Other nesting errors that leave a
</p>without a corresponding opening tag.
Examples
Duplicate closing tag
The simplest case — an extra </p> with no matching opening tag:
<!-- ❌ Bad: duplicate end tag -->
<p>Some text.</p></p>
<!-- ✅ Good: single end tag -->
<p>Some text.</p>
Block-level element nested inside a paragraph
This is the most common and least obvious cause. When a <div> (or other block-level element) appears inside a <p>, the parser closes the <p> implicitly:
<!-- ❌ Bad: div inside p causes implicit closure -->
<p>
Some introductory text.
<div class="highlight">Highlighted content</div>
</p>
The parser interprets this as:
<p>Some introductory text.</p>
<div class="highlight">Highlighted content</div>
</p> ← orphaned end tag, triggers the error
To fix this, either replace the outer <p> with a <div>, or replace the inner <div> with a <span>:
<!-- ✅ Good: use div as the outer container -->
<div>
<p>Some introductory text.</p>
<div class="highlight">Highlighted content</div>
</div>
<!-- ✅ Good: use span instead of div for inline styling -->
<p>
Some introductory text.
<span class="highlight">Highlighted content</span>
</p>
List nested inside a paragraph
Lists are block-level elements and cannot be nested inside <p>:
<!-- ❌ Bad: ul inside p -->
<p>
Choose one of the following:
<ul>
<li>Option A</li>
<li>Option B</li>
</ul>
</p>
<!-- ✅ Good: separate the paragraph and list -->
<p>Choose one of the following:</p>
<ul>
<li>Option A</li>
<li>Option B</li>
</ul>
Orphaned end tag from a deleted opening tag
Sometimes during editing, the opening <p> gets accidentally removed:
<!-- ❌ Bad: missing opening tag -->
<div>
Some text that lost its opening tag.
</p>
</div>
<!-- ✅ Good: restore the opening tag or remove the closing tag -->
<div>
<p>Some text with its opening tag restored.</p>
</div>
When debugging this error, look at the line number reported by the validator and trace backward. If you see a </p> on that line, check whether there's a valid opening <p> for it, and verify that no block-level elements between the opening and closing tags could have caused an implicit closure.
The HTML specification requires that attributes on an element be separated by one or more ASCII whitespace characters. When you omit the space — typically between a closing quote of one attribute's value and the name of the next attribute — the browser may struggle to determine where one attribute ends and the next begins. While some browsers may attempt to parse the element correctly, the behavior is not guaranteed and can lead to unexpected results.
This issue commonly occurs when editing HTML by hand, especially when copying and pasting attributes from different sources or when a template engine concatenates attribute strings without proper spacing. It can also happen when a closing quote is immediately followed by another attribute name, making the markup difficult to read and maintain.
Beyond validation, missing spaces between attributes hurt code readability. Other developers (or your future self) scanning the markup may misread attribute boundaries, leading to bugs that are hard to track down. Consistent spacing also ensures that assistive technologies and browser parsers interpret your elements exactly as intended.
How to Fix It
Go through your HTML and ensure every attribute is separated from adjacent attributes by at least one space character. Pay special attention to:
- Attributes placed immediately after a quoted value (e.g.,
"value"classshould be"value" class). - Attributes placed after unquoted values, which can be even more ambiguous.
- Dynamically generated markup from template engines or JavaScript, where concatenation might drop whitespace.
Examples
Incorrect: No Space Between Attributes
<a href="page.php"class="big">link</a>
Here, class is placed directly after the closing quote of the href value with no space in between. The validator will flag this as an error.
Correct: Space Between Attributes
<a href="page.php" class="big">link</a>
A single space between "page.php" and class resolves the issue.
Incorrect: Multiple Missing Spaces
<img src="photo.jpg"alt="A sunset"width="600"height="400">
All four attributes run together without any whitespace separating them.
Correct: All Attributes Properly Spaced
<img src="photo.jpg" alt="A sunset" width="600" height="400">
Correct: Using Line Breaks as Whitespace
When an element has many attributes, you can use newlines for separation, which also improves readability:
<img
src="photo.jpg"
alt="A sunset"
width="600"
height="400">
Newlines and indentation count as valid whitespace between attributes and are perfectly acceptable in HTML. This multi-line style is especially helpful for elements with numerous attributes, such as <input> fields in forms or components with data attributes.
The doctype's public identifier and system identifier are written back to back, with no space between their two quoted strings.
Legacy doctypes from HTML 4.01 and XHTML 1.0 have two quoted strings after the PUBLIC keyword. The first is the public identifier, which names the DTD, such as "-//W3C//DTD XHTML 1.0 Transitional//EN". The second is the system identifier, the URL of that DTD. The HTML syntax requires whitespace between them, so a closing quote followed directly by an opening quote (//EN""http://) is a parse error. The same applies to single-quoted identifiers.
These doctypes are usually split across two lines, with the URL on the second line. A minifier or template that removes the line break without leaving a space produces this error.
Browsers recover from it: they still read both identifiers, so the page renders in the same mode as it would with the space. The legacy doctype itself is still reported, as "Almost standards mode doctype" or "Obsolete doctype". Adding a space clears this error only. Replacing the declaration with <!DOCTYPE html>, which has no identifiers, clears both.
Invalid example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Products</title>
</head>
<body>
<p>Hello</p>
</body>
</html>
Valid example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Products</title>
</head>
<body>
<p>Hello</p>
</body>
</html>
When the W3C HTML Validator reports "No X element in scope but a X end tag seen," it means the parser encountered a closing tag for an element that was never opened, or that was already closed. The validator tracks which elements are currently "in scope" — meaning which opening tags are still waiting for their corresponding closing tags. When a closing tag appears that doesn't match any open element in scope, this error is raised.
This issue matters for several reasons. First, it indicates malformed HTML that browsers must guess how to interpret, potentially leading to inconsistent rendering across different browsers. Second, broken document structure can confuse assistive technologies like screen readers, harming accessibility. Third, stray end tags can inadvertently affect the DOM tree in unexpected ways, making your CSS and JavaScript behave unpredictably.
There are several common causes:
- Closing a tag twice — the most frequent cause, where a copy-paste error or oversight leads to a duplicate closing tag.
- Missing the opening tag — the corresponding opening tag was accidentally deleted or never added.
- Misnested tags — elements overlap instead of being properly nested, causing the browser to auto-close one element, which makes a later closing tag orphaned.
- Typos in tag names — an opening tag has a different name than the closing tag (e.g.,
<div>opened but</dvi>used to close it, though this usually triggers a different error).
To fix this, carefully review the HTML around the flagged line. Trace each closing tag back to its opening tag. Using a code editor with bracket/tag matching can make this much easier. Remove any duplicate end tags, add any missing opening tags, or fix nesting order as needed.
Examples
Closing a tag twice
This is the most common cause. The </p> tag appears twice:
<!-- ❌ Bad: duplicate closing tag -->
<p>Hello world</p></p>
Remove the extra closing tag:
<!-- ✅ Good -->
<p>Hello world</p>
Missing opening tag
Here a </span> end tag has no corresponding <span>:
<!-- ❌ Bad: no opening <span> -->
<div>
Some text</span>
</div>
Either add the missing opening tag or remove the stray end tag:
<!-- ✅ Good: opening tag added -->
<div>
<span>Some text</span>
</div>
Misnested tags
When elements overlap instead of nesting properly, the browser auto-closes the inner element, leaving a later closing tag orphaned:
<!-- ❌ Bad: <b> and <i> overlap -->
<p><b>Bold and <i>italic</b> text</i></p>
In this case, the browser closes the <i> when it encounters </b> (since <i> is inside <b>), so the later </i> has no element in scope. Fix it by nesting correctly:
<!-- ✅ Good: proper nesting -->
<p><b>Bold and <i>italic</i></b> <i>text</i></p>
Stray end tag after auto-closed element
Some elements like <p> are automatically closed by certain subsequent tags. This can lead to orphaned end tags:
<!-- ❌ Bad: <p> is auto-closed by <div>, leaving </p> orphaned -->
<p>Some text
<div>A block element</div>
</p>
The <p> element cannot contain a <div>, so the browser implicitly closes the <p> before the <div>. The final </p> then has no <p> in scope. Restructure the markup:
<!-- ✅ Good: separate elements -->
<p>Some text</p>
<div>A block element</div>
Tip: use editor tooling
Most modern code editors can highlight matching opening and closing tags. If you see a closing tag without a highlighted match, that's likely the source of this error. Extensions for VS Code, Sublime Text, and other editors can also auto-format and validate your HTML as you type, catching these issues early.
The HTML specification defines a strict structure for documents: the <html> element contains a <head> and a <body>, and all visible page content must live inside the <body>. Once the browser encounters the </body> closing tag, it expects nothing but optional whitespace (spaces, tabs, newlines) before the closing </html> tag. Any non-space characters in that gap — whether text, HTML elements, script tags, or even stray punctuation — are considered outside the document body and trigger this validation error.
Why this matters
- Standards compliance: The HTML living standard (WHATWG) is clear that content after
</body>is not valid. W3C validation will flag this as an error. - Unpredictable rendering: Browsers use error recovery to handle misplaced content, and different browsers may handle it differently. Most will implicitly reopen the
<body>and move the content inside it, but relying on this behavior is fragile and unpredictable. - Accessibility: Screen readers and assistive technologies parse the DOM structure. Content that lands in unexpected places due to error recovery may be announced out of order or missed entirely.
- Maintainability: Stray content after
</body>is often a sign of a code organization problem — a misplaced include, a template rendering issue, or an accidental paste — and cleaning it up improves long-term maintainability.
Common causes
- Accidental text or typos after the closing
</body>tag. - Script or analytics tags mistakenly placed between
</body>and</html>instead of at the end of the<body>. - Server-side template engines appending content after the body in a layout file.
- Comments or debugging output left behind after
</body>.
Examples
Stray text after </body>
This triggers the validation error because the text this is invalid appears after </body>:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<p>Content goes here.</p>
</body> this is invalid
</html>
Move all content inside the <body>:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<p>Content goes here.</p>
</body>
</html>
Script placed outside the body
A common mistake is placing a <script> tag between </body> and </html>:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<p>Main content</p>
</body>
<script src="analytics.js"></script>
</html>
Place the script at the end of the <body> instead:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<p>Main content</p>
<script src="analytics.js"></script>
</body>
</html>
Stray HTML element after </body>
Sometimes an element like a <div> ends up after the body due to a template issue:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<main>Page content</main>
</body>
<div id="overlay"></div>
</html>
Move it inside <body>:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<main>Page content</main>
<div id="overlay"></div>
</body>
</html>
The fix is always the same: ensure that everything between </body> and </html> is either whitespace or nothing at all. All content — text, elements, scripts, and comments — belongs inside the <body> element.
A <noscript> inside the <head> contains text, but there it may only hold <link>, <style> and <meta> elements.
The <head> is never rendered, so a <noscript> placed there can only change metadata, for example by loading a fallback stylesheet. Whitespace and comments are fine. Any other character counts, including , because a non-breaking space isn't whitespace to the HTML parser.
When JavaScript is off, the parser treats that text as the start of the page content. It closes the <noscript> and the <head> early and opens the <body> there. The text and everything after it end up in the body, which is why the validator usually follows this error with Stray end tag “noscript”, Stray end tag “head” and a complaint about a second <body> start tag. Any <meta> or <link> that comes after the <noscript> also lands in the body.
A message for visitors without JavaScript belongs in a <noscript> inside the <body>. Keep the <noscript> in the <head> for metadata only, or remove it.
Invalid example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
<noscript>Please enable JavaScript to use this site.</noscript>
</head>
<body>
<p>Hello</p>
</body>
</html>
Valid example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
<noscript>
<link rel="stylesheet" href="no-js.css">
</noscript>
</head>
<body>
<noscript>
<p>Please enable JavaScript to use this site.</p>
</noscript>
<p>Hello</p>
</body>
</html>
The <!DOCTYPE html> declaration is required by the HTML specification as the first non-whitespace content in any HTML document. It instructs the browser to render the page in standards mode, which means the browser follows modern CSS and HTML specifications faithfully. When the doctype is missing or preceded by other content, browsers fall back to quirks mode — a legacy rendering mode that emulates old browser behaviors and can cause inconsistent layout, box model differences, and other subtle bugs across browsers.
This error is triggered in several common scenarios:
- The
<!DOCTYPE html>declaration is completely absent from the file. - Text, HTML tags, or other non-space characters appear before the doctype.
- A Byte Order Mark (BOM) or invisible characters were inadvertently inserted before the doctype by a text editor.
- Server-side code (such as PHP or template includes) outputs content before the doctype.
- An XML processing instruction like
<?xml version="1.0"?>precedes the doctype (this is unnecessary in HTML5).
Beyond triggering quirks mode, a missing or misplaced doctype breaks standards compliance and can cause real-world rendering issues. For example, in quirks mode, box-sizing defaults differ, table elements don't inherit font sizes properly, and percentage-based heights may not resolve correctly. These problems can be difficult to debug because they only manifest in certain browsers or under specific conditions.
How to Fix
- Open your HTML file and make sure the very first line is
<!DOCTYPE html>with nothing before it — no whitespace characters, no text, no comments, and no BOM. - Check for invisible characters. If you copied content from another source or use a text editor that inserts a BOM, open the file in a hex editor or use your editor's "show invisible characters" feature to confirm nothing precedes the doctype.
- Check server-side scripts. If you use PHP, ASP, or a templating engine, make sure no output (including blank lines or spaces outside script tags) is emitted before
<!DOCTYPE html>. - Remove legacy doctypes or XML declarations. In HTML5, the only doctype you need is
<!DOCTYPE html>. Older doctypes like<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ...>are valid but unnecessary, and XML processing instructions should not be used in HTML documents.
Examples
Missing doctype
This document has no doctype at all, which triggers the error:
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Text before the doctype
Stray text or content before the declaration also triggers the error:
Welcome to my site!
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
PHP output before the doctype
A common server-side issue where whitespace or output leaks before the doctype:
<?php include 'config.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
If config.php has a closing ?> followed by a blank line, that blank line gets sent as output before the doctype. Ensure included files don't produce unintended output.
Correct document
The doctype must be the absolute first thing in the file:
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Note that the doctype declaration is case-insensitive — <!DOCTYPE html>, <!doctype html>, and <!Doctype Html> are all valid. However, <!DOCTYPE html> is the conventional form recommended by the HTML living standard. A single blank line or whitespace-only line before the doctype won't trigger this specific error (since the validator message specifies "non-space characters"), but it's best practice to avoid any content before the declaration to keep your document clean and unambiguous.
The doctype declaration tells the browser which version of HTML the document is written in and determines how the browser renders the page. Older HTML versions required long, complex doctype strings that referenced Document Type Definitions (DTDs). With the introduction of HTML5, the doctype was simplified to just <!DOCTYPE html>, which is now the only recommended doctype for modern web pages.
When a browser encounters an obsolete doctype—or no doctype at all—it may switch into "quirks mode," a legacy rendering mode that emulates old browser behavior. In quirks mode, CSS box models, layout calculations, and other rendering behaviors can differ significantly from standards mode, leading to inconsistent appearance across browsers. Using the modern <!DOCTYPE html> ensures the browser operates in "standards mode," giving you predictable and consistent rendering.
Beyond rendering concerns, using an obsolete doctype means your document is referencing outdated specifications. Modern HTML validators, including the W3C Nu HTML Checker, are designed to validate against the current HTML Living Standard. Legacy doctypes may cause the validator to misinterpret your markup or report errors that don't apply, making it harder to maintain clean, valid code.
To fix this, simply replace whatever doctype declaration appears at the top of your HTML file with <!DOCTYPE html>. This single change is backward-compatible—it works in all modern browsers and even in Internet Explorer 6 and later. No DTD reference or version number is needed.
Examples
Obsolete doctypes that trigger this issue
These are common legacy doctypes that the validator will flag:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>My Page</title>
</head>
<body>
<p>Hello world</p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Page</title>
</head>
<body>
<p>Hello world</p>
</body>
</html>
Correct HTML5 doctype
Replace the obsolete doctype with the simple, modern declaration:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<p>Hello world</p>
</body>
</html>
Key points about the modern doctype
- It must appear on the very first line of the document, before the
<html>tag. No comments or whitespace should precede it. - The declaration is case-insensitive—
<!DOCTYPE html>,<!doctype html>, and<!Doctype Html>are all valid, though lowercase or uppercase conventions are most common. - Unlike older doctypes, it does not reference a DTD URL or version number.
- Adding a
langattribute to the<html>element and a<meta charset="utf-8">tag in the<head>are best practices that pair well with the modern doctype for a fully standards-compliant document.
In CSS, most numeric values represent a length, time, angle, or other dimension, and the unit tells the browser how to interpret the number. Writing padding: 20 is ambiguous — does it mean 20 pixels, 20 ems, or 20 percent? Without a unit, the browser has no way to determine the author's intent, so it treats the value as invalid and discards the entire declaration. This can lead to broken layouts, missing spacing, or other visual problems that are difficult to debug.
The only exception to this rule is 0. Zero pixels is the same as zero ems, zero rems, or zero percent — it's always nothing regardless of the unit. Because of this, the CSS specification allows 0 to be written without a unit. In fact, omitting the unit on zero values is considered a best practice for cleaner, more concise CSS.
This validation error commonly appears in inline style attributes, which is where the W3C HTML Validator encounters it. However, the same rule applies to CSS written in <style> elements and external stylesheets.
Common causes of this error include:
- Accidentally forgetting to type the unit after a number.
- Copy-pasting values from design tools that don't include units.
- Confusing CSS with JavaScript's
element.style.width = "50"pattern (where some APIs accept unitless numbers). - Assuming that
pxis the default unit (it is not — there is no default unit in CSS).
Examples
Incorrect — missing units on numeric values
<div style="margin: 10; padding: 20; width: 300;">
Content here
</div>
The validator will report errors for 10, 20, and 300 because none of them have units.
Correct — units specified on all non-zero values
<div style="margin: 10px; padding: 20px; width: 300px;">
Content here
</div>
Correct — zero without a unit
<div style="margin: 0; padding: 0; border: 0;">
No units needed for zero
</div>
Correct — mixing zero and non-zero values
<div style="margin: 0 10px 0 20px;">
Top and bottom margins are zero, sides have units
</div>
Correct — using other unit types
<p style="font-size: 1.2em; line-height: 1.5em; margin-bottom: 2rem;">
Text with relative units
</p>
Note that line-height is a special case in CSS — it actually accepts a unitless number (like 1.5) as a valid value, where the number acts as a multiplier of the element's font size. This is not the same as a missing unit; it's a deliberately unitless ratio defined in the specification. Most other properties do not have this behavior.
The aria-label attribute defines an accessible name for an element, providing a text label that assistive technologies (like screen readers) can announce to users. It's especially useful when there's no visible text label on screen, such as for icon buttons or navigation landmarks. However, aria-label doesn't work on every HTML element — it only has an effect on elements that have roles which support name from author.
According to the ARIA specification, aria-label is designed to work with interactive elements (like <button>, <a> with href, <input>), landmark and structural roles (like <nav>, <section>, <form>), images (<img>), and elements with explicit widget or landmark roles. When applied to generic elements that have no role (or only the generic implicit role), such as <div> or <span>, the attribute is effectively ignored by assistive technologies. This means users of screen readers won't hear the label, defeating its purpose entirely.
This matters for several reasons:
- Accessibility: Developers may believe they've provided an accessible label when they haven't. Users relying on screen readers will miss the information entirely.
- Standards compliance: The ARIA in HTML specification explicitly prohibits
aria-labelon elements where it has no effect, and the W3C validator flags this as a warning. - Maintainability: Meaningless attributes add noise to the codebase and can mislead future developers about the element's purpose.
To fix this warning, either move the aria-label to an appropriate element, add an explicit role attribute that supports naming, use aria-label on a different wrapping element that supports it, or replace the approach with visible text or a visually-hidden CSS class.
Examples
Incorrect: aria-label on a <div> with no role
A plain <div> has the implicit generic role, which does not support naming. The aria-label will be ignored.
<div aria-label="User profile section">
<img src="avatar.jpg" alt="User avatar">
<p>Jane Doe</p>
</div>
Correct: Use a landmark element or add an appropriate role
Wrapping the content in a <section> element gives it the region landmark role (when labeled), making aria-label valid and meaningful:
<section aria-label="User profile section">
<img src="avatar.jpg" alt="User avatar">
<p>Jane Doe</p>
</section>
Alternatively, add an explicit role to the <div>:
<div role="region" aria-label="User profile section">
<img src="avatar.jpg" alt="User avatar">
<p>Jane Doe</p>
</div>
Incorrect: aria-label on a <span>
<span aria-label="Warning">⚠️</span>
The <span> has the generic role and does not support aria-label.
Correct: Use an appropriate role or element
<span role="img" aria-label="Warning">⚠️</span>
Incorrect: aria-label on a <p> element
<p aria-label="Important note">Please read the terms carefully.</p>
The <p> element has the paragraph role, which does not support naming via aria-label.
Correct: Use visible text or restructure
If you need to provide additional context, consider restructuring:
<section aria-label="Important note">
<p>Please read the terms carefully.</p>
</section>
Or simply ensure the visible text is sufficiently descriptive, removing the unnecessary aria-label:
<p><strong>Important note:</strong> Please read the terms carefully.</p>
Common elements where aria-label works correctly
<!-- Interactive elements -->
<button aria-label="Close dialog">✕</button>
<a href="/home" aria-label="Go to homepage">🏠</a>
<input type="search" aria-label="Search the site">
<!-- Landmark elements -->
<nav aria-label="Main navigation">
<ul>
<li><a href="/">Home</a></li>
</ul>
</nav>
<form aria-label="Newsletter signup">
<input type="email" aria-label="Email address">
<button>Subscribe</button>
</form>
<!-- Images -->
<img src="chart.png" aria-label="Sales data for Q4 2024">
Quick reference: elements that do not support aria-label
Without an explicit role, aria-label will be flagged on these common elements: <div>, <span>, <p>, <b>, <i>, <em>, <strong>, <small>, <code>, <pre>, <blockquote>, <ul>, <ol>, <li>, <dl>, <dt>, <dd>, <table>, <thead>, <tbody>, and <tfoot>, among others. If you need aria-label on one of these, consider whether a more semantic element or an explicit ARIA role is the right solution first.
The rel attribute on an <a> element has the value noindex, which is not a recognized link type. The validator matched it against the registered keywords and guessed it might be a misspelling of index.
In practice noindex is rarely a typo for index. Authors usually write rel="noindex" because they want to keep a page out of search results, but rel cannot do that. The attribute describes the relationship between the current document and the linked resource, not whether a page should be indexed.
Indexing is a page-level directive. To keep a page out of search results, add a robots meta tag to that page's <head>, or send the equivalent X-Robots-Tag HTTP header. Both apply to the page being excluded, not to a link pointing at it.
If your goal is to stop search engines from passing ranking through a link, the correct rel value is nofollow.
Invalid example
<a href="/private" rel="noindex">Members area</a>
Valid example
Use rel="nofollow" on the link when you want search engines to ignore it:
<a href="/private" rel="nofollow">Members area</a>
To keep the destination page itself out of search results, control indexing on that page instead:
<meta name="robots" content="noindex">
The rel attribute on an <a> element contains a token that looks like a misspelled link type, such as _nofollow where nofollow was meant.
rel holds a space-separated list of keywords that describe how the current page relates to the linked resource. Browsers and search engines only act on the keywords they recognize, and they compare each token as written, ignoring case. A near miss such as _nofollow, nofolow or no-follow is not read as nofollow, so search engines see an ordinary followed link. A misspelled noreferer has a similar effect: the browser still sends the Referer header to the destination. The HTTP header is spelled with one "r", but the keyword is noreferrer.
The validator does not report every unknown token, because rel also accepts extension values defined outside the HTML standard. It warns only when a token is close to a known keyword, and the message ends with the keyword it suspects you meant. When the attribute holds several tokens, the message quotes the whole value, so check each token to find the misspelled one.
A leading underscore is a frequent cause. Keywords for the target attribute start with one (_blank, _self), and the habit carries over to rel on the same link. No rel keyword starts with an underscore.
Invalid example
<a href="https://example.com/" target="_blank" rel="_nofollow">Partner site</a>
<a href="https://example.org/" rel="noreferer">Another site</a>
Valid example
<a href="https://example.com/" target="_blank" rel="nofollow">Partner site</a>
<a href="https://example.org/" rel="noreferrer">Another site</a>
The doctype declaration tells browsers which version of HTML a page uses and, critically, determines whether the browser renders the page in standards mode or quirks mode. Standards mode follows current CSS and HTML specifications, while quirks mode emulates the buggy behavior of older browsers from the late 1990s and early 2000s. When the W3C validator reports "Quirky doctype," it means your document's doctype is one that is known to trigger quirks mode—and in the context of modern HTML, this is always undesirable.
Several legacy doctypes can trigger this warning, including:
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">(without a system identifier URL)<!DOCTYPE html public "-//W3C//DTD HTML 3.2 Final//EN">- Malformed or incomplete doctype declarations
- Doctypes with unexpected casing or extra whitespace in certain positions
The HTML Living Standard (maintained by WHATWG) specifies that the doctype must be <!DOCTYPE html>. This short declaration is case-insensitive but is conventionally written in uppercase. It exists solely to trigger standards mode—it does not reference a DTD because HTML5 is not based on SGML.
Why This Matters
Inconsistent rendering: In quirks mode, browsers alter how they calculate the box model, handle table sizing, apply inline element dimensions, and more. A page that looks correct in one browser may break in another because each browser's quirks mode emulates different legacy behaviors.
Accessibility and interoperability: Screen readers and other assistive technologies rely on predictable DOM behavior. Quirks mode can cause unexpected layout shifts and content reflow that degrade the experience for users of assistive technology.
Standards compliance: Modern HTML validators expect the HTML5 doctype. Using a legacy doctype signals that the document is not following current web standards, which can also affect SEO tools and automated audits.
How to Fix It
- Open your HTML file and locate the very first line.
- Replace whatever doctype declaration is there with
<!DOCTYPE html>. - Ensure nothing appears before the doctype—no whitespace, no comments, no byte order marks (BOMs). Any content before the doctype can also trigger quirks mode in some browsers.
- Verify that the rest of your document uses valid HTML5 syntax (e.g., the
<html>tag includes alangattribute, the<head>contains a<meta charset>declaration and a<title>element).
Examples
Incorrect: Legacy doctype triggering quirks mode
<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>My Page</title>
</head>
<body>
<p>This page renders in quirks mode.</p>
</body>
</html>
This HTML 4.0 Transitional doctype without a system identifier URL is a known quirks-mode trigger.
Incorrect: Another common quirky doctype
<!DOCTYPE html public "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>My Page</title>
</head>
<body>
<p>This older doctype also triggers quirks mode.</p>
</body>
</html>
Correct: Standard HTML5 doctype
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<p>This page renders in standards mode.</p>
</body>
</html>
The simple <!DOCTYPE html> declaration ensures standards mode across all modern browsers. It is the only doctype you should use for new HTML documents, and it is also fully backward-compatible with older browsers—even Internet Explorer 6 renders in standards mode with this doctype.
When the HTML parser encounters a tag's attributes, it expects a specific structure: an attribute name, followed by an equals sign, followed by a quoted value. If a quote character appears where the parser expects an attribute name, it means something has gone wrong in the syntax earlier in the tag. The validator flags this as Quote """ in attribute name and suggests that a matching quote is likely missing somewhere before.
This issue matters because browsers will try to recover from the malformed HTML in unpredictable ways. One browser might ignore the attribute entirely, while another might merge it with adjacent text. This can lead to broken styling, missing functionality, or elements that behave differently across browsers. For accessibility, malformed attributes can prevent assistive technologies from correctly interpreting element semantics and roles.
There are several common causes for this error:
- Missing equals sign between an attribute name and its value, causing the parser to treat the opening quote as part of the attribute name.
- Extra closing quote that prematurely ends an attribute value, leaving subsequent quotes orphaned.
- Unescaped quotes inside attribute values, which break the quoting structure of the entire tag.
- Copy-paste errors that introduce curly/smart quotes (
"") or extra quote characters. - A missing closing quote on a previous attribute, causing the parser to consume subsequent attributes as part of that value.
Examples
Missing equals sign
The most common cause. Without the =, the parser sees class as one attribute and then encounters " where it expects another attribute name.
❌ Incorrect:
<p class"news">This paragraph has broken markup.</p>
✅ Fixed:
<p class="news">This paragraph has correct markup.</p>
Missing closing quote on a previous attribute
When a quote is left unclosed, everything after it—including other attributes—gets consumed as part of the value, until the parser eventually encounters another quote in an unexpected position.
❌ Incorrect:
<a href="/about class="link">About us</a>
Here, the href value is never closed. The parser reads /about class= as the href value, then encounters "link" in an unexpected context.
✅ Fixed:
<a href="/about" class="link">About us</a>
Extra quote character
A stray extra quote breaks the pairing of subsequent quotes.
❌ Incorrect:
<div id=""main" class="container">Content</div>
✅ Fixed:
<div id="main" class="container">Content</div>
Unescaped quotes inside an attribute value
If the attribute value itself contains a double quote, it must be escaped as " or the attribute must use single quotes instead.
❌ Incorrect:
<input type="text" value="She said "hello"">
✅ Fixed (using "):
<input type="text" value="She said "hello"">
✅ Also fixed (using single quotes for the attribute):
<input type="text" value='She said "hello"'>
Smart/curly quotes from copy-paste
Word processors and rich-text editors often convert straight quotes to curly quotes, which are not valid for HTML attribute delimiters.
❌ Incorrect:
<p class="highlight">Styled text</p>
✅ Fixed:
<p class="highlight">Styled text</p>
How to debug this issue
When you see this error, the validator usually points to a specific line number, but the root cause may be on that line or earlier in the same tag. Follow these steps:
- Go to the line indicated by the validator and examine the full tag.
- Check every attribute on that element for proper
name="value"syntax. - Count the quotes — each attribute value should have exactly one opening and one closing quote.
- Look for missing
=signs between attribute names and their values. - Search for curly quotes (
",",',') and replace them with straight quotes ("or'). - If the line looks correct, check the preceding lines — an unclosed quote on a previous element can cascade errors into later markup.
When you submit a URL to the W3C HTML Validator, it attempts to fetch the page from your server just like a browser would. If the server doesn't respond within the validator's timeout window, the validation process is aborted and you see a "Read timed out" error. No HTML checking occurs at all — the validator never received any markup to analyze.
Common Causes
Several things can trigger this timeout:
- Slow server response: Your server may be under heavy load, running slow database queries, or experiencing resource constraints that delay the response.
- Large page size: Pages with extremely large HTML output can take too long to transmit within the allowed time.
- Geographic latency: The W3C Validator's servers may be geographically distant from your server, adding network delay.
- Firewall or security rules: A firewall, CDN, or WAF (Web Application Firewall) may be blocking or throttling the validator's requests, treating them as bot traffic.
- DNS resolution issues: Your domain's DNS may be slow to resolve or temporarily unavailable.
- Server downtime: The server may simply be offline or unreachable at the time of validation.
How to Fix It
1. Use Direct Input Instead
The most reliable workaround is to copy your page's HTML source and paste it directly into the validator. This bypasses the network fetch entirely.
- Open your page in a browser.
- View the page source (usually
Ctrl+UorCmd+U). - Copy the entire HTML.
- Go to the W3C Validator and select the Validate by Direct Input tab.
- Paste the HTML and click Check.
2. Upload the File
If you have the HTML file locally, use the Validate by File Upload tab to upload it directly. This also avoids any network timeout issues.
3. Fix Server-Side Issues
If you need URL-based validation (for example, in a CI/CD pipeline), address the underlying server problem:
- Check server health: Ensure your server is running and responding to requests within a reasonable time (under a few seconds).
- Whitelist the validator: If you use a WAF or rate limiter, ensure requests from the W3C Validator's user agent are not being blocked or delayed.
- Reduce page size: If your HTML output is extremely large, consider whether it can be simplified or paginated.
- Try again later: Temporary network issues or server load spikes may resolve on their own. Simply retrying after a few minutes often works.
4. Run a Local Validator
For frequent validation or automated workflows, consider running the Nu Html Checker locally. This eliminates network dependencies entirely:
java -jar vnu.jar your-page.html
Examples
Triggering the Issue
Submitting a URL where the server is slow or unreachable:
https://example-slow-server.com/heavy-page.html
The validator returns:
Read timed out
No HTML validation results are provided.
Workaround: Validate by Direct Input
Instead of submitting the URL, paste the HTML source directly:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This content is validated without fetching from a server.</p>
</body>
</html>
This gives you full validation results regardless of server availability or response time.
Summary
The "Read timed out" error is purely a network/server issue, not an HTML quality issue. Your markup might be perfectly valid — the validator just can't reach it. Use direct input or file upload as an immediate workaround, and investigate server-side causes if you specifically need URL-based validation.
The HTML specification requires that every row in a table has at least one cell that starts on that row. A "cell beginning on a row" means a <td> or <th> element that is directly placed in that <tr>, as opposed to a cell that merely spans into it via rowspan from an earlier row. When the validator encounters a row with no cells beginning on it, it flags the error because the row is structurally meaningless — it contributes nothing to the table's data model.
This issue commonly arises in two scenarios:
- Empty
<tr>elements — A<tr>that contains no<td>or<th>children at all. This sometimes appears when developers use empty rows for visual spacing, or when content management systems generate leftover markup. - Rows fully covered by
rowspan— When cells in preceding rows userowspanvalues large enough to span over an entire subsequent row, that subsequent row ends up with no cells beginning on it, even if it technically "has" cells passing through it.
This matters for several reasons. Screen readers and other assistive technologies rely on a well-formed table structure to navigate cells and announce their content. An empty or fully-spanned row confuses this navigation. Browsers may also handle malformed tables inconsistently, leading to unexpected rendering. Ensuring every row has at least one cell that begins on it keeps your tables semantically correct and accessible.
How to fix it
- Remove empty rows. If a
<tr>has no cells and serves no purpose, delete it entirely. - Add cells to the row. If the row is intentional, populate it with
<td>or<th>elements (they can be empty if needed). - Adjust
rowspanvalues. If previous cells span too many rows, reduce theirrowspanso that every row still has at least one cell of its own. - Use CSS for spacing. If empty rows were used for visual spacing, use CSS
margin,padding, orborder-spacinginstead.
Note that self-closing <tr /> elements are treated the same as <tr></tr> — they produce an empty row and will trigger this error.
Examples
Empty row in <tbody> (incorrect)
<table>
<tbody>
<tr>
</tr>
<tr>
<td>Data</td>
</tr>
</tbody>
</table>
The first <tr> has no cells, so the validator reports that row 1 of the <tbody> row group has no cells beginning on it.
Empty row removed (correct)
<table>
<tbody>
<tr>
<td>Data</td>
</tr>
</tbody>
</table>
Row fully covered by rowspan (incorrect)
<table>
<tbody>
<tr>
<td rowspan="3">Spans three rows</td>
<td rowspan="3">Also spans three</td>
</tr>
<tr>
</tr>
<tr>
</tr>
</tbody>
</table>
Rows 2 and 3 have no cells beginning on them — all cells originate from row 1. Even though cells pass through those rows via rowspan, the validator still requires at least one cell to begin on each row.
Corrected rowspan with cells on every row (correct)
<table>
<tbody>
<tr>
<td rowspan="3">Spans three rows</td>
<td>Row 1 detail</td>
</tr>
<tr>
<td>Row 2 detail</td>
</tr>
<tr>
<td>Row 3 detail</td>
</tr>
</tbody>
</table>
Each row now has at least one <td> that begins on it, satisfying the requirement.
Using CSS instead of empty rows for spacing (correct)
<table>
<tbody>
<tr>
<td>First item</td>
</tr>
<tr style="height: 1.5em;">
<td>Second item with extra space above</td>
</tr>
</tbody>
</table>
Instead of inserting an empty row for spacing, apply CSS to the row or cells that need additional space.
A <style> element in the <body> contains an @import rule, which the HTML standard doesn't allow there.
Since October 2026, a <style> element can sit in the <body> as long as its styles can't reach anything earlier in the page. Its style rules have to go inside an @scope block, and it can't use @import at all. The rules in an imported file aren't scoped, so they would apply to the whole page. Every @import in the element triggers the error, including ones with layer() or a media query, even when the rest of the style sheet is valid.
Moving the @import into the @scope block doesn't work either. CSS only accepts @import at the top of a style sheet, before other rules, so the validator reports a CSS parse error instead. Older validator builds worded this message differently and mentioned @scope, but the problem and the fix are the same.
To fix the error, load the file with a <link rel="stylesheet"> element. A stylesheet link is allowed in the <body>, but the linked rules still apply to the whole page, so the <head> is the more usual place for it. If the imported rules only target this part of the page, copy them into the @scope block of the <style> element instead. A <style> in the <body> also has to stay the first child of its parent.
Invalid example
<div class="card">
<style>
@import url("card.css");
@scope {
p {
color: darkslategray;
}
}
</style>
<p>Card content</p>
</div>
Valid example
<div class="card">
<style>
@scope {
p {
color: darkslategray;
}
}
</style>
<link rel="stylesheet" href="card.css">
<p>Card content</p>
</div>
Older builds of the validator reported at-rules like @keyframes and @font-face outside an @scope block in a <style> element in the <body>, but the HTML standard allows them there.
Since October 2026, a <style> element can sit in the <body> as long as its styles can't reach anything earlier in the page. Its style rules have to go inside an @scope block, and it can't use @import. An earlier draft of that change allowed only a few at-rules at the top level of the style sheet, such as @media, @supports and @layer. Builds of the Nu HTML Checker from late September and early October 2026 followed the draft and reported every other at-rule with this message.
The final rule lets at-rules that don't select elements stay outside @scope, at the top level or inside @media. That includes @keyframes, @font-face, @page and @counter-style. Current builds of the validator don't report them, so the code doesn't need to change: validate the page again and the error goes away. @import is still not allowed, and it now has a message of its own.
The names these at-rules define, such as an animation name or a font family, apply to the whole page. The HTML standard suggests using them only in the scoped rules of the same <style> element, and picking names that nothing else on the page uses. That way they can't restyle content the browser has already drawn.
Example
Older builds reported both at-rules in this <style> element. Current builds accept it, because the only style rule is inside @scope:
<div class="card">
<style>
@font-face {
font-family: "Card Sans";
src: url("card-sans.woff2") format("woff2");
}
@keyframes card-fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@scope {
p {
font-family: "Card Sans", sans-serif;
animation: card-fade-in 0.3s ease-in;
}
}
</style>
<p>Card content</p>
</div>
A <form> can't contain another <form>, so when the parser finds a second <form> start tag while one is still open, it drops that tag along with its action, method and id.
The fields inside the ignored form then belong to the outer one. In the invalid example below, the "Delete account" button submits the account form to /account, and nothing is ever sent to /account/delete. The inner </form> also closes the outer form early, so any fields after it end up outside any form, and the validator reports the last </form> as Stray end tag “form”.
A common cause is a page template that wraps the whole page in one form, with a search box or newsletter signup inside it that adds a form of its own. A missing </form> causes it too. If the parent element of the first form closes before the form does, the parser still treats that form as active, and it ignores the next <form> on the page.
Move the inner form out so the two forms are siblings. When a button or field has to stay inside one form's layout but submit a different form, give that form an id and point the control at it with the form attribute: <button type="submit" form="delete-account">. The <button>, <input>, <select> and <textarea> elements all accept form. The form it points to can sit anywhere in the document, and it can be empty, as in the valid example below.
Invalid example
<form action="/account" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email">
<button type="submit">Save</button>
<form action="/account/delete" method="post">
<button type="submit">Delete account</button>
</form>
</form>
Valid example
<form action="/account" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email">
<button type="submit">Save</button>
<button type="submit" form="delete-account">Delete account</button>
</form>
<form id="delete-account" action="/account/delete" method="post"></form>
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries