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.
HTML does not define the element named in this message, and its name does not qualify as a custom element, so the validator rejects it wherever it appears.
Browsers still show the content of an unknown tag. They treat the tag as a generic inline element with no default styling, no meaning and no accessibility role, so its text renders as if the tag weren't there. The validator reports it because nothing in the HTML standard says what the element is.
The same tag also triggers a second error, Element "X" not allowed as child of element "Y" in this context, and the fix below clears both. The validator writes the element name in lowercase, so <st1:City> is reported as st1:city.
Most unknown elements come from one of these sources:
- A typo in a real element name, such as
<buton>or<sectoin>. - Markup left behind by Microsoft Word when a document is saved as HTML or pasted into an editor. Word adds tags with a namespace prefix:
<o:p>around paragraph content,<w:...>for document settings, and "smart tags" like<st1:place>,<st1:city>or<st1:metricconverter>around places, dates and measurements. - Tag names invented for styling or scripting, such as
<tabs>or<icon>, or placeholders from a widget or template engine that were never replaced.
Correct the name if it's a typo. For Word markup, delete the tags and keep the text inside them, since the wrapper does nothing in a browser. Most editors and CMSs have a "paste as plain text" option that keeps this markup out in the first place.
If you need an element of your own, give it a custom element name: lowercase, starting with a letter, and containing a hyphen, such as <unit-converter>. The validator accepts that name, and you can define its behavior with customElements.define().
Invalid example
<p>The table is <st1:metricconverter productid="120 cm">120 cm</st1:metricconverter> wide.</p>
<buton type="button">Add to cart</buton>
Valid example
<p>The table is 120 cm wide.</p>
<button type="button">Add to cart</button>
Valid example with a custom element
<p>The table is <unit-converter value="120" unit="cm">120 cm</unit-converter> wide.</p>
<script>
customElements.define("unit-converter", class extends HTMLElement {});
</script>
Inline SVG in an HTML document can only contain elements that SVG defines, and the element named in this message isn't one of them.
This message usually comes from editor metadata. Inkscape (and Sodipodi, the editor it grew out of) writes two extra things into its SVG files: a <metadata> block that describes the file in RDF, using Dublin Core (dc:) and Creative Commons (cc:) terms, and a <sodipodi:namedview> element that stores editor settings such as the page color and zoom level. Paste the file into a page, or let a build tool inline it, and all of that comes along.
In a standalone SVG file, those prefixes point to other XML namespaces. The HTML parser doesn't treat a prefix as a namespace, so <rdf:RDF> becomes an SVG element whose name happens to contain a colon. SVG has no element by that name, and the validator reports each one it finds: rdf:rdf, cc:work, dc:format, dc:type, dc:title and sodipodi:namedview. Names are reported in lowercase, so <cc:Work> shows up as cc:work.
The outermost element of each block also gets a second error, such as Element "rdf:rdf" not allowed as child of element "metadata" in this context, and the same fix clears both. A misspelled SVG element like <circel> triggers this message too, and there the fix is to correct the spelling.
The <metadata> element itself is valid. The validator accepts it empty or with plain text inside; only the RDF markup nested in it fails. None of this markup is drawn, so removing it doesn't change how the image looks.
The same export usually puts xmlns:dc, xmlns:cc, xmlns:rdf, xmlns:sodipodi and xmlns:inkscape declarations on the <svg> element, plus prefixed attributes such as inkscape:version and sodipodi:docname. The validator reports those separately (Attribute "xmlns:rdf" not allowed here.), and they go in the same cleanup:
- Delete the
<metadata>block and the<sodipodi:namedview>element. - Delete the
xmlns:declarations and everyinkscape:orsodipodi:attribute.
If the image needs a title, use SVG's own <title> element, which also gives the image an accessible name.
To clean files before they reach the page, run them through SVGO. Its default preset includes removeMetadata and removeEditorsNSData, which strip both kinds of markup. In Inkscape, Save As "Optimized SVG" can remove metadata as well. "Plain SVG" drops the Inkscape and Sodipodi markup but can leave the <metadata> block in place.
Invalid example
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24" height="24" viewBox="0 0 24 24">
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Search</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview pagecolor="#ffffff" inkscape:zoom="8" />
<circle cx="10" cy="10" r="7" fill="none" stroke="currentColor" stroke-width="2" />
<path d="M15 15l6 6" stroke="currentColor" stroke-width="2" />
</svg>
Valid example
<svg width="24" height="24" viewBox="0 0 24 24" role="img">
<title>Search</title>
<circle cx="10" cy="10" r="7" fill="none" stroke="currentColor" stroke-width="2" />
<path d="M15 15l6 6" stroke="currentColor" stroke-width="2" />
</svg>
A page can have only one element with the autofocus attribute, and so can each <dialog> and each popover on it.
The HTML standard groups autofocus elements by their "nearest ancestor autofocus scoping root element". For an element inside a <dialog>, or inside an element with the popover attribute, that root is the closest such ancestor. A <dialog> or popover that has autofocus itself is its own root. Everything else on the page shares one root, the <html> element. When two elements with autofocus end up with the same root, the validator reports this error.
The rule follows from how browsers use the attribute. On page load, the browser focuses one autofocus element, normally the first in source order, and ignores the rest. A <dialog> or popover can have its own autofocus element because the browser moves focus into it each time it opens.
A common cause is a site header whose search field has autofocus, on a page whose main form uses it too. Keep autofocus on the one field people most likely want to type in first, and remove it from the others. A modal built from a plain <div> doesn't get its own root, even with role="dialog". If the second field belongs in a modal, build the modal with <dialog> or the popover attribute, and its autofocus no longer clashes with the page's.
Invalid example
<header>
<form action="/search" role="search">
<input type="search" name="q" aria-label="Search" autofocus>
</form>
</header>
<main>
<form action="/login" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username" autofocus>
<label for="password">Password</label>
<input type="password" id="password" name="password">
<button type="submit">Sign in</button>
</form>
</main>
Valid example
Only the login form's first field keeps autofocus:
<header>
<form action="/search" role="search">
<input type="search" name="q" aria-label="Search">
</form>
</header>
<main>
<form action="/login" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username" autofocus>
<label for="password">Password</label>
<input type="password" id="password" name="password">
<button type="submit">Sign in</button>
</form>
</main>
When the search field lives in a <dialog>, both fields can keep autofocus, because each has a different root:
<main>
<form action="/login" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username" autofocus>
<label for="password">Password</label>
<input type="password" id="password" name="password">
<button type="submit">Sign in</button>
</form>
</main>
<dialog id="search-dialog">
<form action="/search" role="search">
<input type="search" name="q" aria-label="Search" autofocus>
<button type="submit">Search</button>
</form>
</dialog>
The dir attribute specifies the base text direction for the content of an element. When a document is written in a right-to-left language like Arabic, Hebrew, Persian (Farsi), or Urdu, the browser needs to know that text should flow from right to left. Without this attribute, browsers default to left-to-right (ltr) rendering, which can cause a range of problems: text alignment may be incorrect, punctuation can appear in the wrong place, and the overall page layout may look broken or confusing to native readers.
This matters for several important reasons:
- Accessibility: Screen readers and other assistive technologies rely on the
dirattribute to correctly announce and navigate content. Without it, the reading experience for users relying on these tools may be disorienting or incorrect. - Visual correctness: Elements like lists, tables, form labels, and navigation menus will mirror their layout in RTL mode. Without
dir="rtl", these elements default to LTR positioning, which feels unnatural for RTL language speakers. - Bidirectional text handling: Documents often contain mixed-direction content (e.g., Arabic text with embedded English words, numbers, or brand names). The Unicode Bidirectional Algorithm (BiDi) uses the base direction set by
dirto correctly resolve the ordering of these mixed runs of text. - Standards compliance: The WHATWG HTML Living Standard recommends that authors set the
dirattribute to match the language of the document, and the W3C Internationalization guidelines strongly encourage it for RTL languages.
How to fix it
Add dir="rtl" to your <html> start tag. If you haven't already, also include the appropriate lang attribute for the specific language you're using.
For Arabic:
<html dir="rtl" lang="ar">
For Hebrew:
<html dir="rtl" lang="he">
For Persian:
<html dir="rtl" lang="fa">
Examples
❌ Missing dir attribute on an Arabic document
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="utf-8">
<title>مرحبا بالعالم</title>
</head>
<body>
<h1>مرحبا بالعالم</h1>
<p>هذه صفحة تجريبية باللغة العربية.</p>
</body>
</html>
The browser will render this page with a left-to-right base direction. The heading and paragraph text may appear left-aligned, and any mixed-direction content (like embedded numbers or English words) may be ordered incorrectly.
✅ Correct: dir="rtl" added to the <html> tag
<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
<meta charset="utf-8">
<title>مرحبا بالعالم</title>
</head>
<body>
<h1>مرحبا بالعالم</h1>
<p>هذه صفحة تجريبية باللغة العربية.</p>
</body>
</html>
Now the browser knows to render the page right-to-left. Text will be right-aligned by default, scroll bars will appear on the left, and the overall layout will feel natural for Arabic readers.
Handling mixed-direction content within a page
If your RTL document contains sections in a left-to-right language, use the dir attribute on individual elements to override the base direction locally:
<p>قام المستخدم بزيارة <span dir="ltr">www.example.com</span> اليوم.</p>
This ensures the URL renders in the correct left-to-right order while the surrounding Arabic text flows right-to-left. Setting dir="rtl" on the <html> element establishes the correct default, and you only need per-element overrides for embedded LTR content.
The lang attribute on the <html> element declares the primary language of the document's content. When this attribute is left empty (lang=""), it effectively tells browsers and assistive technologies that the language is unknown or intentionally unspecified — which is almost never what you want.
This matters for several important reasons:
- Accessibility: Screen readers rely on the
langattribute to select the correct pronunciation engine. An empty value can cause a screen reader to fall back to a default language, potentially reading English text with incorrect pronunciation rules. - Search engines: Search engines use the
langattribute to understand what language your content is in, which helps serve your pages to the right audience. - Browser features: Browsers use the language declaration for hyphenation, spell-checking, font selection, and other language-sensitive rendering decisions.
- Standards compliance: The WHATWG HTML living standard specifies that if the
langattribute is present, its value must be a valid BCP 47 language tag. An empty string is not a valid language tag.
The fix is straightforward: set the lang attribute to a valid BCP 47 language tag that matches your content. For English, common values include en (general English), en-US (American English), or en-GB (British English). If your content is in another language, use the appropriate tag (e.g., fr for French, de for German, ja for Japanese).
Examples
❌ Empty lang attribute (triggers the warning)
<!DOCTYPE html>
<html lang="">
<head>
<title>My Page</title>
</head>
<body>
<h1>Welcome to my website</h1>
</body>
</html>
❌ Missing lang attribute entirely
While a missing lang attribute triggers a different warning, it causes the same underlying problem — no language is declared:
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Welcome to my website</h1>
</body>
</html>
✅ Correct: specifying the language
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<h1>Welcome to my website</h1>
</body>
</html>
✅ Correct: using a regional variant
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>My Page</title>
</head>
<body>
<h1>Welcome to my website</h1>
</body>
</html>
Using lang for mixed-language content
If your document is primarily in English but contains sections in other languages, set lang="en" on the <html> element and override it on specific elements:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Multilingual Page</title>
</head>
<body>
<h1>Welcome</h1>
<p>This page contains a quote in French:</p>
<blockquote lang="fr">
<p>La vie est belle.</p>
</blockquote>
</body>
</html>
The lang attribute on the <html> element declares the primary language of the document. The W3C validator uses heuristics to analyze the text content of your page, and when it detects a mismatch between the declared language and the apparent language, it raises this warning. For example, if your page content is written in English but lang="fr" (French) is set, the validator will flag this inconsistency.
Why This Matters
The lang attribute plays a critical role in several areas:
- Accessibility: Screen readers use the
langattribute to select the correct pronunciation rules and voice profile. If a page is written in English but declares French, a screen reader may attempt to read the content with French pronunciation, making it unintelligible to the user. - Search engines: Search engines use the
langattribute to understand what language a page is in, which affects how the page is indexed and served in search results for different regions. - Browser features: Browsers rely on the
langattribute for built-in translation prompts, spell-checking, hyphenation, and font selection. An incorrect value can cause unexpected behavior in all of these areas.
How to Fix It
- Identify the primary language of your content. Look at the actual text on your page — what language is the majority of it written in?
- Update the
langattribute to the correct BCP 47 language tag for that language (e.g.,enfor English,frfor French,esfor Spanish). - If the
langattribute is already correct and the validator's heuristic is wrong (e.g., your page genuinely is in another language but contains some English text or code), you can safely ignore this warning.
For pages with mixed-language content, set the lang attribute on <html> to the primary language, then use lang attributes on specific elements to mark sections in other languages.
Examples
❌ Incorrect: Content is in English but lang declares French
<!DOCTYPE html>
<html lang="fr">
<head>
<title>My Website</title>
</head>
<body>
<h1>Welcome to my website</h1>
<p>This is an English paragraph about web development.</p>
</body>
</html>
The validator detects that the content is English, but lang="fr" says it's French.
✅ Fixed: lang attribute matches the content language
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Website</title>
</head>
<body>
<h1>Welcome to my website</h1>
<p>This is an English paragraph about web development.</p>
</body>
</html>
✅ Mixed-language content with proper lang attributes
If your page is primarily in English but contains sections in another language, set the document language to en and annotate the foreign-language sections individually:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Language Examples</title>
</head>
<body>
<h1>Welcome</h1>
<p>This page is mostly in English.</p>
<blockquote lang="fr">
<p>Ceci est une citation en français.</p>
</blockquote>
</body>
</html>
This approach ensures screen readers switch pronunciation only for the French <blockquote>, while the rest of the page is correctly read as English.
The lang attribute on the <html> element tells browsers, search engines, and assistive technologies what language the page content is written in. The validator uses heuristic analysis of the actual text on the page to detect the likely language, and when there's a mismatch, it flags the discrepancy.
Why This Matters
An incorrect lang attribute causes real problems for users and systems that rely on it:
- Screen readers use the
langattribute to select the correct pronunciation engine. A French document marked as English will be read aloud with English pronunciation rules, making it incomprehensible. - Search engines use the language declaration for indexing and serving results to users searching in a specific language.
- Browser features like automatic translation prompts and spell-checking rely on the declared language.
- Hyphenation and typographic rules in CSS also depend on the correct language being declared.
Common Causes
- Copy-pasting a boilerplate — Starting from an English template but writing content in another language without updating
lang. - Multilingual sites — Using the same base template for all language versions without dynamically setting the
langvalue. - Incorrect language subtag — Using the wrong BCP 47 language tag (e.g.,
lang="en"instead oflang="de"for German content).
When You Can Safely Ignore This Warning
This is a warning, not an error. The validator's language detection is heuristic and not always accurate. You may safely ignore it if:
- Your page contains very little text, making detection unreliable.
- The page has significant amounts of content in multiple languages, but the
langattribute correctly reflects the primary language. - The detected language is simply wrong (e.g., short text snippets can confuse the detector).
If you're confident the lang attribute is correct, you can disregard the warning.
How to Fix It
Identify the primary language of your document's content and set the lang attribute to the appropriate BCP 47 language tag. Common tags include en (English), fr (French), de (German), es (Spanish), pt (Portuguese), ja (Japanese), and zh (Chinese).
Examples
Incorrect: Content in French, but lang set to English
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mon site</title>
</head>
<body>
<h1>Bienvenue sur notre site</h1>
<p>Nous sommes ravis de vous accueillir sur notre plateforme.</p>
</body>
</html>
This triggers the warning because the validator detects French content but sees lang="en".
Fixed: lang attribute matches the content language
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Mon site</title>
</head>
<body>
<h1>Bienvenue sur notre site</h1>
<p>Nous sommes ravis de vous accueillir sur notre plateforme.</p>
</body>
</html>
Handling mixed-language content
If your page is primarily in one language but contains sections in another, set the lang attribute on the <html> element to the primary language and use lang on specific elements for the other language:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Our Global Site</title>
</head>
<body>
<h1>Welcome to our site</h1>
<p>We are glad you are here.</p>
<blockquote lang="fr">
<p>La vie est belle.</p>
</blockquote>
</body>
</html>
This tells assistive technologies that the page is in English, but the blockquote should be read using French pronunciation rules. The validator should not flag this as a mismatch because the majority of the content is in English.
The lang attribute on the <html> element declares the primary language of the document's content. When this attribute is missing or set incorrectly, the validator analyzes the text content and attempts to detect the language automatically. If it identifies a likely language, it produces this warning suggesting you add the appropriate lang value.
This matters for several important reasons:
- Accessibility: Screen readers rely on the
langattribute to select the correct pronunciation rules and voice profile. Without it, a screen reader might attempt to read Spanish text using English phonetics, producing unintelligible speech for the user. - Browser behavior: Browsers use the language declaration for hyphenation, quotation mark styling, spell-checking, and font selection. For example, the CSS
hyphens: autoproperty depends on thelangattribute to apply language-appropriate hyphenation rules. - Search engines: Search engines use the
langattribute as a signal to understand the language of your content, which helps serve it to the right audience in search results. - Translation tools: Automatic translation services use the declared language to determine whether (and from which language) to offer translation.
The value of the lang attribute must be a valid BCP 47 language tag. Common examples include en (English), es (Spanish), fr (French), de (German), zh (Chinese), ja (Japanese), and ar (Arabic). You can also specify regional variants like en-US, en-GB, pt-BR, or es-MX.
Examples
Missing lang attribute
This triggers the warning because the validator detects the content language but finds no lang declaration:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mi Sitio Web</title>
</head>
<body>
<h1>Bienvenido a mi sitio web</h1>
<p>Este es un párrafo en español.</p>
</body>
</html>
Fixed with the correct lang attribute
Adding lang="es" tells browsers, screen readers, and search engines that this document is in Spanish:
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Mi Sitio Web</title>
</head>
<body>
<h1>Bienvenido a mi sitio web</h1>
<p>Este es un párrafo en español.</p>
</body>
</html>
Mismatched lang attribute
This can also trigger the warning when the lang value doesn't match the actual content. Here, the content is in French but the language is declared as English:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mon Site Web</title>
</head>
<body>
<h1>Bienvenue sur mon site web</h1>
<p>Ceci est un paragraphe en français.</p>
</body>
</html>
The fix is to correct the lang value to match the content:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Mon Site Web</title>
</head>
<body>
<h1>Bienvenue sur mon site web</h1>
<p>Ceci est un paragraphe en français.</p>
</body>
</html>
Using a regional variant
If you need to specify a regional variation, append the region subtag. For example, es-MX for Mexican Spanish or pt-BR for Brazilian Portuguese:
<!DOCTYPE html>
<html lang="es-MX">
<head>
<meta charset="UTF-8">
<title>Mi Sitio Web</title>
</head>
<body>
<h1>Bienvenido a mi sitio web</h1>
<p>Este es un párrafo en español de México.</p>
</body>
</html>
Sections in a different language
When your document is primarily in one language but contains sections in another, set the main language on <html> and use lang on individual elements for the exceptions:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
</head>
<body>
<h1>Welcome to my website</h1>
<p>This site is available in multiple languages.</p>
<blockquote lang="es">
<p>Bienvenido a mi sitio web.</p>
</blockquote>
</body>
</html>
This approach ensures that assistive technologies switch pronunciation rules appropriately when they encounter the foreign-language section, while browsers and search engines still understand the primary document language.
A document lacks a heading with a computed level of 1, which means there is no <h1> element (or an element whose final heading level resolves to 1) on the page.
The W3C validator raises this as a warning because every document should have at least one <h1> to identify its main topic. Screen readers and search engines rely on the heading hierarchy to understand page structure, and <h1> is the expected entry point of that hierarchy.
A "computed heading level" differs from the literal tag name only when the now-obsolete <hgroup> algorithm or the abandoned outline algorithm would adjust levels. In practice, for nearly all documents, a computed level of 1 simply means an <h1> tag.
This warning appears when a page uses <h2>, <h3>, or other headings but skips <h1> entirely. Adding a single <h1> that describes the page content fixes the warning.
Example with the warning
<!DOCTYPE html>
<html lang="en">
<head>
<title>My page</title>
</head>
<body>
<h2>About us</h2>
<p>Welcome to our site.</p>
<h3>Our team</h3>
<p>We are a small group.</p>
</body>
</html>
Fixed example
<!DOCTYPE html>
<html lang="en">
<head>
<title>My page</title>
</head>
<body>
<h1>My page</h1>
<h2>About us</h2>
<p>Welcome to our site.</p>
<h3>Our team</h3>
<p>We are a small group.</p>
</body>
</html>
Each page should have exactly one <h1>. If the design calls for the <h1> to be visually hidden (for example, when a logo replaces the text), use a CSS technique to hide it from sighted users while keeping it accessible to screen readers, rather than removing it from the markup.
An empty action attribute on a <form> element is not valid HTML. To submit a form to the current page URL, remove the action attribute entirely.
When a <form> has no action attribute, the browser submits the form data to the URL of the current document. This is the same behavior most developers expect from action="", but the empty string is not a valid URL according to the HTML specification. The W3C validator flags this because the action attribute, when present, must contain a valid non-empty URL.
Removing the attribute is the correct fix. The HTML living standard explicitly states that omitting action causes the form to submit to the document's own URL.
HTML examples
Invalid empty action
<form action="" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email">
<button type="submit">Subscribe</button>
</form>
Fixed by removing the action attribute
<form method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email">
<button type="submit">Subscribe</button>
</form>
Void elements — such as area, base, br, col, embed, hr, img, input, link, meta, source, track, and wbr — cannot have child content or a closing tag. They are inherently self-closing. In XHTML, a trailing slash (<br />) was required to make the document well-formed XML, but in HTML5 (the current standard), the slash is entirely optional and has no effect on how the element is parsed.
While the trailing slash is technically permitted, it creates a real risk when used alongside unquoted attribute values. The HTML parser does not treat the slash as a special self-closing token in the way you might expect. Instead, if the last attribute's value is unquoted, the slash becomes part of that value. This can silently break your page — the browser won't report an error, but the attribute value will be wrong.
Beyond this parsing hazard, removing trailing slashes keeps your markup cleaner and avoids ambiguity. The W3C validator raises this as a warning to help you catch potential issues before they cause hard-to-debug problems.
Why this matters
- Silent bugs: When a trailing slash is absorbed into an unquoted attribute value, it changes the value without any visible error. For example, a URL ending in
/instead of the intended value can cause broken images, failed resource loads, or incorrect behavior. - Standards compliance: The WHATWG HTML Living Standard specifies that the trailing slash on void elements is allowed but has no effect. The validator warns about it because of the interaction with unquoted attributes.
- Code clarity: Removing trailing slashes makes it clear that you're writing HTML, not XHTML, and avoids confusing developers who may not be aware of the parsing nuance.
How to fix it
- Remove trailing slashes from all void elements. Write
<br>instead of<br/>,<img src="photo.jpg" alt="Photo">instead of<img src="photo.jpg" alt="Photo"/>, and so on. - If you prefer to keep trailing slashes, always quote your attribute values. Quoted values prevent the parser from absorbing the slash into the attribute.
- Configure your editor or formatter — some tools (e.g., Prettier) have options to add or remove trailing slashes. Check your formatter's settings and disable automatic trailing slash insertion for HTML files.
Examples
Trailing slash absorbed into an unquoted attribute value
In this example, the parser interprets the trailing slash as part of the src value, resulting in http://example.com/logo.svg/ instead of the intended http://example.com/logo.svg:
<!-- ❌ Wrong: the slash becomes part of the src value -->
<img alt=SVG src=http://example.com/logo.svg/>
Fix by removing the trailing slash
The simplest and recommended fix — just drop the slash:
<!-- ✅ Correct: no trailing slash -->
<img alt=SVG src=http://example.com/logo.svg>
Fix by quoting attribute values
If you want to keep the trailing slash for stylistic reasons, quoting the attribute values prevents the slash from being absorbed:
<!-- ✅ Correct: quoted attributes prevent the parsing issue -->
<img alt="SVG" src="http://example.com/logo.svg" />
Common void elements with unnecessary trailing slashes
<!-- ❌ Trailing slashes have no effect -->
<br/>
<hr/>
<input type="text" name="query"/>
<meta charset="utf-8"/>
<link rel="stylesheet" href="style.css"/>
<!-- ✅ Preferred: clean void elements without trailing slashes -->
<br>
<hr>
<input type="text" name="query">
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
A subtle real-world bug
Consider a meta tag with an unquoted content value:
<!-- ❌ The slash is parsed as part of the content value -->
<meta name=theme-color content=#ffffff/>
The browser reads the content value as #ffffff/ instead of #ffffff, which is not a valid color and will be ignored. The fix:
<!-- ✅ No trailing slash -->
<meta name="theme-color" content="#ffffff">
The <span> element is an inline container used to mark up a portion of text or a group of inline elements, typically for styling or scripting purposes. Like most HTML elements, it requires both an opening <span> tag and a closing </span> tag. When the closing tag is missing, the browser's HTML parser must determine where the element ends on its own. Different browsers may handle this differently, potentially wrapping more content inside the <span> than intended.
This is problematic for several reasons:
- Unexpected styling: If the
<span>has CSS applied to it (via aclass,id, or inlinestyle), the styles may bleed into sibling or subsequent elements that were never meant to be affected. - Broken document structure: An unclosed
<span>inside a<p>element can cause the parser to implicitly close and reopen elements in unexpected ways, distorting the DOM tree. - Accessibility concerns: Screen readers and assistive technologies rely on a well-formed DOM. An unclosed element can cause content to be grouped or announced incorrectly.
- Maintenance difficulty: Unclosed elements make the markup harder to read, debug, and maintain over time.
A common scenario is forgetting the closing tag when the <span> wraps only part of a paragraph's text. Another frequent cause is mismatched or misordered nesting, where the closing tags appear in the wrong sequence.
Examples
Unclosed <span> inside a paragraph
The closing </span> is missing entirely, so the browser has to guess where the span ends:
<!-- ❌ Bad: unclosed <span> -->
<p><span class="highlight">I'm forgetting something</p>
<p>Life goes on</p>
Add the missing </span> before the content that shouldn't be wrapped:
<!-- ✅ Good: <span> is properly closed -->
<p><span class="highlight">I'm forgetting something</span></p>
<p>Life goes on</p>
Incorrectly nested closing tags
Sometimes the closing tags are present but in the wrong order. Tags must be closed in the reverse order they were opened:
<!-- ❌ Bad: closing tags are misordered -->
<p><em><span class="note">Important text</em></span></p>
<!-- ✅ Good: tags closed in correct (reverse) order -->
<p><em><span class="note">Important text</span></em></p>
Multiple <span> elements with a missing close
When using several <span> elements in sequence, it's easy to lose track:
<!-- ❌ Bad: second <span> is never closed -->
<p>
<span class="first-name">Jane</span>
<span class="last-name">Doe
</p>
<!-- ✅ Good: all <span> elements are closed -->
<p>
<span class="first-name">Jane</span>
<span class="last-name">Doe</span>
</p>
Tips for avoiding unclosed elements
- Indent consistently. Proper indentation makes it much easier to spot a missing closing tag.
- Write both tags at once. When you type
<span>, immediately type</span>and then fill in the content between them. - Use an editor with auto-closing and bracket matching. Most modern code editors will highlight unmatched tags.
- Validate regularly. Run your markup through the W3C HTML Validator often, especially after larger edits.
Every non-void HTML element needs a matching end tag. When one is missing, the browser's error recovery kicks in and decides where the element ends. The resulting DOM tree can differ from what the source code suggests, breaking layout, CSS selectors, and JavaScript that depends on a specific structure. Screen readers and other assistive technologies also rely on correct nesting to convey document structure to users.
This error commonly appears when tags are closed out of order. HTML requires last-in-first-out nesting: the most recently opened element must be closed first. Another frequent cause is copy-paste editing that removes a closing tag while leaving the opener behind. Note that void elements (<br>, <img>, <input>, <meta>, <hr>, <link>) never have closing tags. Writing <br></br> is invalid in HTML and can trigger a related error.
Examples
Missing closing tag
<!-- Bad: the outer <div> is never closed -->
<div class="card">
<h2>Title</h2>
<p>Some text</p>
<div class="footer">
<p>Footer text</p>
</div>
Fixed
<div class="card">
<h2>Title</h2>
<p>Some text</p>
<div class="footer">
<p>Footer text</p>
</div>
</div>
Out-of-order closing tags
<!-- Bad: <em> is opened inside <strong> but closed after </strong> -->
<p><strong><em>Important</strong></em> notice</p>
Fixed
<p><strong><em>Important</em></strong> notice</p>
Consistent indentation makes nesting mismatches easier to spot by eye. Editor features like bracket matching, and tools like Prettier or HTMLHint, can catch these problems before you run the validator. If you use a templating language, make sure conditional blocks do not skip required end tags.
The document was decoded with a legacy encoding, usually windows-1252, and contains a byte that has no character in that encoding.
A character encoding maps bytes to characters. In windows-1252, five byte values map to nothing: 81, 8d, 8f, 90 and 9d. The message gives the byte that failed in hexadecimal.
Most of the time the file is saved as UTF-8, but nothing says so. With no <meta charset> in the page and no charset in the HTTP Content-Type header, the validator has to guess the encoding and often picks windows-1252. UTF-8 stores accented letters as two bytes, and for some of them the second byte is one of the unmapped values: Í is c3 8d and č is c4 8d. Read as windows-1252, the first byte turns into the wrong character (Ã or Ä) and the second can't be decoded at all. A browser that guesses the same way shows that garbled text to visitors.
Declare UTF-8 with <meta charset="utf-8"> as the first element inside <head>. This also clears the "The character encoding was not declared" error that usually comes with this one. If the server sends a Content-Type header with a legacy charset such as iso-8859-1, change the server configuration as well, because the header takes priority over the <meta> element.
If the file really is saved as windows-1252, the byte is broken data, often from text pasted out of a document in another encoding. Convert the file to UTF-8, then find the damaged character and type it again.
Invalid example
A file saved as UTF-8 and served without a charset:
<!DOCTYPE html>
<html lang="es">
<head>
<title>Índice</title>
</head>
<body>
<h1>Índice</h1>
</body>
</html>
Valid example
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<title>Índice</title>
</head>
<body>
<h1>Índice</h1>
</body>
</html>
This warning appears when an <svg> element has version="1.0" or version="1.2", because the W3C validator only checks inline SVG against SVG 1.1. Removing the version attribute clears the warning and won't change how browsers draw the graphic.
The version attribute was meant to declare which SVG specification the content targets. The validator has no ruleset for SVG 1.0 or 1.2, so it falls back to this warning. Other values, such as "2.0", get a different error instead: Bad value “2.0” for attribute “version” on element “svg”. Browsers ignore the attribute when rendering, so dropping it has no visible effect.
This usually shows up in files exported from drawing tools, which write a version attribute by default. The baseProfile attribute is obsolete for inline SVG in HTML5 for the same reason, so you can remove it too.
Invalid example
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<rect x="10" y="10" width="80" height="80" fill="teal" />
</svg>
Valid example
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<rect x="10" y="10" width="80" height="80" fill="teal" />
</svg>
If you have a lot of SVG files to clean up, an optimizer like SVGO can strip the version attribute automatically.
In older HTML practices, developers sometimes used <meta http-equiv="Content-Language" content="en"> inside the <head> to declare the document's primary language. The HTML living standard now marks this as obsolete because it was an unreliable and indirect way to communicate language information. It attempted to mirror an HTTP header rather than being a true part of the document structure, and its behavior was inconsistently implemented across browsers.
The lang attribute on the <html> element is the correct modern approach. It directly associates the language with the document's DOM tree, which has several important benefits:
- Accessibility: Screen readers rely on the
langattribute to select the correct pronunciation rules and voice profile. Without it, assistive technology may mispronounce content or fall back to a default language that doesn't match the text. - Browser behavior: Browsers use the
langattribute to make decisions about hyphenation, font selection, quotation mark styling, spell-checking, and other language-sensitive rendering. - Search engines: Declaring the language helps search engines index and serve content to the appropriate audience.
- CSS targeting: The
:lang()pseudo-class selector works based on thelangattribute, enabling language-specific styling.
The lang attribute also supports granular, element-level language declarations. If your page is primarily in English but contains a French quote, you can set lang="fr" on that specific element — something the <meta> approach could never do.
Examples
Incorrect: using the obsolete meta tag
This triggers the W3C validation warning because <meta http-equiv="Content-Language"> is obsolete for specifying the document language.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<title>My Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Correct: using the lang attribute on <html>
Remove the <meta http-equiv="Content-Language"> tag and add the lang attribute to the <html> element instead.
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Correct: mixed-language content
Use the lang attribute on the root element for the primary language, then override it on specific elements as needed.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Multilingual Page</title>
</head>
<body>
<p>The French word for hello is <span lang="fr">bonjour</span>.</p>
<blockquote lang="de">
<p>Die Grenzen meiner Sprache bedeuten die Grenzen meiner Welt.</p>
</blockquote>
</body>
</html>
Common language codes
Use a valid BCP 47 language tag as the value of the lang attribute. Here are some frequently used codes:
| Code | Language |
|---|---|
en | English |
fr | French |
de | German |
es | Spanish |
pt-BR | Brazilian Portuguese |
zh-Hans | Simplified Chinese |
ja | Japanese |
The fix is straightforward: remove any <meta http-equiv="Content-Language"> tags from your <head> and ensure your <html> element includes a lang attribute with the appropriate language code. This single change resolves the validation warning while improving your document's accessibility, rendering, and standards compliance.
The encodings iso-8859-1 (also known as Latin-1) and windows-1252 (also called CP-1252) share the same character mappings for most byte values, but they diverge in the range 0x80 to 0x9F. In iso-8859-1, these bytes map to obscure control characters. In windows-1252, they map to useful printable characters like curly quotes (" "), em dashes (—), the euro sign (€), and the trademark symbol (™). Because Windows text editors historically saved files in windows-1252, many documents declared as iso-8859-1 actually contain windows-1252-specific characters in that byte range.
When the validator encounters bytes in the 0x80–0x9F range in a file declared as iso-8859-1, it knows the file is actually windows-1252, because those bytes would be meaningless control characters under true iso-8859-1. This triggers the warning.
Modern browsers already handle this situation by treating any iso-8859-1 declaration as windows-1252 — the WHATWG Encoding Standard explicitly maps the label iso-8859-1 to the windows-1252 encoding. So in practice, browsers won't break. However, the mismatch still matters for standards compliance, and it signals that you may not have full control over your document's encoding, which can cause subtle bugs in other tools, server configurations, or data processing pipelines.
Why This Matters
- Standards compliance: Declaring one encoding while using another violates the HTML specification's requirement that the declared encoding match the actual encoding of the document.
- Interoperability: While browsers handle this gracefully, other HTML consumers — such as search engine crawlers, screen readers, email clients, or server-side parsers — may not apply the same
iso-8859-1-to-windows-1252mapping, leading to garbled characters. - Maintainability: An encoding mismatch is a sign of a fragile build process. If you ever need to transcode, concatenate, or process your files programmatically, an incorrect declaration can cause data corruption.
How to Fix It
You have three options, listed from most to least recommended:
Option 1: Convert to UTF-8 (Recommended)
UTF-8 is the universal standard for the web. It supports every Unicode character, is the default encoding in the WHATWG HTML Standard, and eliminates this entire class of problems.
- Open your file in your text editor or IDE.
- Re-save it with UTF-8 encoding (most modern editors default to this).
- Declare
utf-8in your<meta>tag. - Verify that special characters (curly quotes, em dashes, etc.) still display correctly after conversion.
Option 2: Declare windows-1252
If you can't convert to UTF-8, update your declaration to match the actual encoding:
- Keep the file saved as
windows-1252. - Change your
<meta>tag to declarewindows-1252.
Option 3: Actually save as iso-8859-1
If you truly need iso-8859-1, you must ensure the file contains no bytes in the 0x80–0x9F range. This means removing or replacing characters like curly quotes, em dashes, and the euro sign, since they don't exist in iso-8859-1.
Examples
Triggering the warning
This document declares iso-8859-1, but if the file is saved in windows-1252 and contains characters like curly quotes or em dashes in the 0x80–0x9F byte range, the validator will report the mismatch:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="iso-8859-1">
<title>My Page</title>
</head>
<body>
<!-- If this file contains windows-1252 bytes like curly quotes or em dashes,
the validator will warn about the encoding mismatch -->
<p>She said, “Hello!”</p>
</body>
</html>
Fix: Convert to UTF-8
The best solution is to save the file as UTF-8 and declare it accordingly:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<p>She said, "Hello!"</p>
</body>
</html>
In UTF-8, curly quotes, em dashes, euro signs, and every other Unicode character are natively supported — no more byte-range conflicts.
Fix: Declare windows-1252 explicitly
If converting to UTF-8 isn't feasible, make the declaration honest:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="windows-1252">
<title>My Page</title>
</head>
<body>
<p>Price: 50€ — bargain!</p>
</body>
</html>
This eliminates the warning because the declared encoding now matches the actual encoding of the file.
Checking your file's encoding
Most code editors show the current file encoding in the status bar. In VS Code, for example, click the encoding label in the bottom-right corner to re-open the file with a different encoding or save it with a new one. When converting from windows-1252 to UTF-8, always verify that special characters survived the conversion by inspecting the rendered page.
The xml:lang attribute is a holdover from XHTML, where it was the standard way to declare the language of an element. In HTML5 (the text/html serialization), the lang attribute is the proper way to specify language. The HTML specification allows xml:lang for compatibility purposes, but only if it is accompanied by a lang attribute with an identical value. If xml:lang appears alone, or if its value doesn't match the lang attribute, the document is non-conforming.
This matters for several reasons. Screen readers and other assistive technologies rely on the lang attribute—not xml:lang—to determine pronunciation and language-specific behavior. Search engines also use lang for content indexing and language detection. Having xml:lang without lang means the language declaration may be ignored entirely, degrading both accessibility and SEO.
In modern HTML5 documents, there is rarely a reason to include xml:lang at all. The lang attribute alone covers all use cases. The only scenario where you might need both is if your document must be compatible with both HTML and XHTML parsers (polyglot markup), in which case the two attributes must carry the same value.
How to Fix
You have two options:
- Remove
xml:langand use onlylang(recommended for HTML5 documents). - Add a
langattribute that matches the existingxml:langvalue (for polyglot documents).
If you do keep both attributes, make sure the values are exactly the same—including case and subtags. For example, lang="en-US" must be paired with xml:lang="en-US", not xml:lang="en".
Examples
Incorrect: xml:lang without lang
<html xml:lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p xml:lang="fr">Bonjour le monde</p>
</body>
</html>
This triggers the validation error because both the <html> and <p> elements have xml:lang but no lang attribute.
Incorrect: Mismatched values
<html lang="en" xml:lang="en-US">
<head>
<title>My Page</title>
</head>
<body>
<p>Hello world</p>
</body>
</html>
Even though both attributes are present, the values "en" and "en-US" don't match, which is also invalid.
Correct: Using only lang (recommended)
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p lang="fr">Bonjour le monde</p>
</body>
</html>
This is the cleanest approach for HTML5 documents. The lang attribute is all you need.
Correct: Both attributes with matching values (polyglot)
<!DOCTYPE html>
<html lang="en" xml:lang="en">
<head>
<title>My Page</title>
</head>
<body>
<p lang="fr" xml:lang="fr">Bonjour le monde</p>
</body>
</html>
If you must keep xml:lang, every element that has it must also have lang with the exact same value.
The srcset attribute lets you provide multiple image sources so the browser can select the most appropriate one. There are two types of descriptors you can use in srcset: pixel density descriptors (e.g., 1x, 2x) and width descriptors (e.g., 400w, 800w). When you use pixel density descriptors, the browser already knows the relationship between each source — it simply picks the one matching the device's pixel ratio. But width descriptors work differently. They tell the browser the intrinsic pixel width of each image file, and the browser then needs to know how wide the image will actually be rendered on screen to calculate which file is the best fit. That's exactly what the sizes attribute provides.
The sizes attribute accepts a comma-separated list of media conditions paired with length values, plus a default length. For example, sizes="(max-width: 600px) 100vw, 50vw" tells the browser: "If the viewport is 600px wide or less, this image will occupy 100% of the viewport width; otherwise, it will occupy 50%." Armed with this information and the width descriptors in srcset, the browser can do the math and download only the most suitable image — before CSS or layout has even been calculated.
Why this matters
- Standards compliance: The HTML specification requires
sizeswheneversrcsetuses width descriptors. Omitting it produces invalid HTML. - Correct image selection: Without
sizes, browsers fall back to assuming the image will be100vwwide, which often leads to downloading unnecessarily large images on desktop layouts where the image is much smaller than the full viewport. - Performance: Serving oversized images wastes bandwidth and slows page load. A proper
sizesattribute ensures the browser downloads the smallest sufficient image. - Predictable behavior: Relying on the browser's fallback assumption (
100vw) makes your responsive images behave inconsistently and defeats the purpose of providing multiple candidates.
How to fix it
- Identify every
img(orsource) element that uses width descriptors insrcset. - Determine how wide the image will be displayed at different viewport sizes. You can inspect this with your browser's developer tools or by reviewing your CSS.
- Add a
sizesattribute that describes those widths using media conditions and CSS length values likepx,vw,em, orcalc()expressions.
Examples
Incorrect — missing sizes with width descriptors
<img
src="photo-400.jpg"
srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1200.jpg 1200w"
alt="A mountain landscape">
This triggers the validation error because the browser sees width descriptors (400w, 800w, 1200w) but has no sizes attribute to determine the image's rendered width.
Correct — sizes attribute added
<img
src="photo-400.jpg"
srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1200.jpg 1200w"
sizes="(max-width: 600px) 100vw, (max-width: 1000px) 50vw, 600px"
alt="A mountain landscape">
Here, the sizes attribute tells the browser:
- On viewports up to 600px wide, the image fills 100% of the viewport.
- On viewports between 601px and 1000px, the image fills 50% of the viewport.
- On larger viewports, the image is displayed at a fixed 600px width.
Correct — pixel density descriptors (no sizes needed)
<img
src="logo-1x.png"
srcset="logo-1x.png 1x, logo-2x.png 2x"
alt="Company logo">
When using pixel density descriptors (1x, 2x) instead of width descriptors, the sizes attribute is not required. The browser simply matches the descriptor to the device's pixel ratio.
Correct — using sizes with a <picture> element
<picture>
<source
srcset="hero-400.webp 400w, hero-800.webp 800w"
sizes="(max-width: 800px) 100vw, 800px"
type="image/webp">
<img
src="hero-800.jpg"
srcset="hero-400.jpg 400w, hero-800.jpg 800w"
sizes="(max-width: 800px) 100vw, 800px"
alt="Hero banner">
</picture>
The sizes attribute is required on both the source and img elements when either uses width descriptors in its srcset.
When you write an attribute value without quotes, the HTML parser follows strict rules about which characters are permitted. According to the WHATWG HTML specification, unquoted attribute values cannot contain spaces, ", ', =, <, >, or the backtick character. If any of these characters appear, the parser may misinterpret where the attribute value ends, potentially merging multiple attributes, breaking your markup, or producing unexpected rendering. URL query strings are an especially common trigger because they naturally contain &, =, and ? characters.
This is a problem for several reasons:
- Parsing errors: Browsers use error recovery when encountering malformed attributes, but different browsers may recover differently, leading to inconsistent behavior.
- Broken functionality: A URL like
page.html?id=5&sort=namein an unquotedhrefwill be parsed incorrectly — the browser may interpretsort=nameas a separate HTML attribute rather than part of the URL. - Attributes running together: If you forget a closing quote on one attribute, the parser may consume the next attribute's name and value as part of the first attribute's value, silently breaking your element.
- Standards compliance: Quoting all attribute values is a best practice recommended by the HTML specification for clarity and reliability.
The simplest and most robust fix is to always quote your attribute values using double quotes ("...") or single quotes ('...'). This eliminates ambiguity regardless of what characters the value contains.
Examples
Unquoted URL query string
A URL with query parameters in an unquoted href triggers this error because & and = confuse the parser:
<!-- ❌ Invalid: unquoted attribute value with query string -->
<a href=https://example.com/search?q=html&lang=en>Search</a>
The parser may interpret lang=en as a separate HTML attribute on the <a> element rather than part of the URL.
<!-- ✅ Valid: attribute value properly quoted -->
<a href="https://example.com/search?q=html&lang=en">Search</a>
Attributes running together
A missing closing quote causes the next attribute to be absorbed into the first:
<!-- ❌ Invalid: missing closing quote on class causes attributes to merge -->
<div class="important id="main">Content</div>
The parser sees important id= as part of the class value, and "main" may be interpreted unpredictably.
<!-- ✅ Valid: both attributes properly quoted -->
<div class="important" id="main">Content</div>
Unquoted values with special characters
Even simple values can cause issues if they contain characters not allowed in unquoted attributes:
<!-- ❌ Invalid: unquoted value with characters that confuse the parser -->
<input type=text value=hello world>
<div class=important"></div>
In the first example, world is parsed as a separate attribute, not part of the value. In the second, the stray " after important triggers the error.
<!-- ✅ Valid: all attribute values are quoted -->
<input type="text" value="hello world">
<div class="important"></div>
Simple unquoted values (technically valid but discouraged)
While simple unquoted values without special characters are technically allowed by the spec, quoting them is strongly recommended for consistency and to avoid mistakes:
<!-- Technically valid but discouraged -->
<div class=important></div>
<!-- ✅ Recommended: always use quotes -->
<div class="important"></div>
Adopting the habit of always quoting attribute values prevents this entire class of validation errors and makes your HTML easier to read and maintain.
The X-UA-Compatible directive was introduced to control which rendering engine Internet Explorer would use when displaying a page. Setting it to a specific version like IE=10 locks the page into that version's rendering mode, even if the user has a newer version of Internet Explorer installed. This is problematic because it prevents the browser from using its most capable, standards-compliant rendering engine and can lead to unexpected layout or functionality issues.
The value IE=edge tells Internet Explorer to use the latest rendering engine available, which ensures the best possible standards compliance and feature support. The HTML specification and the W3C validator enforce this requirement because pinning to a specific IE version serves no forward-compatible purpose and can actively degrade the browsing experience.
It's worth noting that with Internet Explorer now being retired and replaced by Microsoft Edge, this meta tag is largely historical. However, if you include it at all, the validator requires that it be set to IE=edge. If your site no longer needs to support legacy versions of Internet Explorer, you can also simply remove the X-UA-Compatible declaration entirely — modern browsers ignore it.
How to fix it
- Find any
<meta http-equiv="X-UA-Compatible">tag in your HTML<head>. - Change the
contentattribute value from the specific version (e.g.,IE=10) toIE=edge. - If the directive is set as an HTTP response header on your server, update the header value there as well.
- Alternatively, remove the tag or header entirely if you no longer need IE compatibility.
Examples
Incorrect: pinned to a specific IE version
This triggers the validator error because IE=10 locks rendering to Internet Explorer 10 mode:
<meta http-equiv="X-UA-Compatible" content="IE=10">
Other version-specific values that would also trigger this error include IE=9, IE=11, IE=EmulateIE10, and similar variations.
Correct: using IE=edge
Replace the version-specific value with IE=edge:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Correct: full document example
When included in a complete HTML document, the X-UA-Compatible meta tag should appear early in the <head>, ideally right after the <meta charset> declaration:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My Page</title>
</head>
<body>
<p>Page content goes here.</p>
</body>
</html>
Correct: removing the tag entirely
If IE support is no longer a concern, the simplest fix is to remove the meta tag altogether:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<p>Page content goes here.</p>
</body>
</html>
Server-side HTTP header
If the X-UA-Compatible value is being sent as an HTTP response header rather than a meta tag, update your server configuration. For example, in Apache:
# Incorrect
Header set X-UA-Compatible "IE=10"
# Correct
Header set X-UA-Compatible "IE=edge"
Or in Nginx:
# Incorrect
add_header X-UA-Compatible "IE=10";
# Correct
add_header X-UA-Compatible "IE=edge";
The X-UA-Compatible header tells Internet Explorer which rendering engine to use for a page. Setting it to IE=edge instructs IE to use the highest available standards mode, ensuring the best compatibility and avoiding legacy rendering quirks. The ,chrome=1 directive was an addition that told browsers with the Google Chrome Frame plugin installed to use Chrome's rendering engine instead of IE's. Google discontinued Chrome Frame in 2014, and the W3C validator only accepts IE=edge as a valid value for this header.
Including the deprecated chrome=1 directive causes a validation error and serves no practical purpose on modern websites. No current browser recognizes or acts on it, so it's dead code that only creates noise in your markup.
The fix is straightforward: remove ,chrome=1 from the content attribute, leaving only IE=edge.
Examples
Incorrect
The following triggers the validation error because of the ,chrome=1 suffix:
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
Correct
Simply use IE=edge as the sole value:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Full document example
If you include this meta tag in a complete HTML document, place it early in the <head>:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My Web Page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Server-side configuration
If you set X-UA-Compatible as an HTTP response header rather than a meta tag, apply the same fix there. For example, in an Apache .htaccess file:
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=edge"
</IfModule>
In Nginx:
add_header X-UA-Compatible "IE=edge";
Is this meta tag still needed?
With Internet Explorer reaching end of life, the X-UA-Compatible meta tag itself is largely unnecessary for new projects. If your site no longer needs to support IE, you can safely remove the tag entirely. If you do keep it for legacy support, ensure the value is exactly IE=edge with no additional directives.
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