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.
Every CSS property has a defined value syntax that specifies exactly which values it accepts and how many. When the validator encounters a declaration that doesn't match this syntax, it flags the error. This can happen for several distinct reasons:
- Too many values: A property receives more values than its syntax allows. For example,
marginaccepts one to four values, so a fifth value is invalid. Thecolorproperty accepts only a single color value, so writing two colors is an error. - Unrecognized values: A keyword is misspelled (e.g.,
blockyinstead ofblock) or simply doesn't exist for that property (e.g.,color: bold). - Newer or non-standard values: A value that belongs to a draft specification, a vendor-prefixed feature, or a browser-specific extension may not be recognized by the validator.
- Missing separators or syntax errors: A missing comma in a multi-value function like
rgb()or a missing slash in shorthand likefontcan cause the parser to misinterpret the values.
This matters because browsers handle invalid CSS unpredictably — they typically discard the entire declaration, which means your intended styles silently disappear. Fixing these errors ensures your styles are applied consistently across browsers and makes your stylesheets easier to maintain and debug.
How to Fix
- Identify the property and value reported in the error message.
- Check spelling of every keyword. Common mistakes include
inheret(should beinherit),trasparent(should betransparent), andcentre(should becenter). - Count the values and compare against the property's specification. Consult MDN Web Docs for the accepted value syntax.
- Verify function syntax — ensure commas, slashes, and parentheses are correct in functions like
rgb(),calc(), andclamp(). - Check for unsupported modern syntax — if you're using newer CSS features, the validator may not recognize them yet. In that case, verify the syntax is correct per the spec and consider the warning informational.
Examples
Too many values for a property
The color property only accepts a single color value, and margin accepts at most four values:
<!-- ❌ Invalid: too many values -->
<p style="color: red blue;">Hello</p>
<p style="margin: 10px 20px 5px 0px 15px;">Hello</p>
<!-- ✅ Valid: correct number of values -->
<p style="color: red;">Hello</p>
<p style="margin: 10px 20px 5px 0px;">Hello</p>
Unrecognized keyword value
A typo or non-existent keyword triggers the error:
<!-- ❌ Invalid: "blocky" is not a valid display value -->
<div style="display: blocky;">Content</div>
<!-- ✅ Valid: correct keyword -->
<div style="display: block;">Content</div>
Misspelled value in a <style> block
<!-- ❌ Invalid -->
<style>
.box {
background-color: trasparent;
text-align: centre;
}
</style>
<!-- ✅ Valid -->
<style>
.box {
background-color: transparent;
text-align: center;
}
</style>
Incorrect function syntax
Missing commas or extra arguments inside CSS functions can also trigger this error:
<!-- ❌ Invalid: missing commas in rgb() -->
<p style="color: rgb(255 0 0 0.5);">Hello</p>
<!-- ✅ Valid: use the correct modern syntax with a slash for alpha -->
<p style="color: rgb(255 0 0 / 0.5);">Hello</p>
Shorthand property confusion
Shorthand properties like font and background have specific value order requirements. Providing values in the wrong order or mixing incompatible values causes errors:
<!-- ❌ Invalid: incorrect font shorthand -->
<style>
p {
font: bold Arial 16px;
}
</style>
<!-- ✅ Valid: size must come before family, weight before size -->
<style>
p {
font: bold 16px Arial;
}
</style>
When in doubt, break shorthand properties into their individual longhand properties (font-weight, font-size, font-family) to isolate which value the validator is rejecting.
In CSS, a "dimension" is a number immediately followed by a unit identifier — for example, 16px, 2em, or 100vh. When the validator encounters a dimension token with a unit it doesn't recognize, it flags it as an unknown dimension. The "X" in the error message is replaced with the actual unrecognized value, such as 10quux or 5pixels.
This issue commonly arises from:
- Typos in unit names — writing
10pxlinstead of10px, or2emsinstead of2em. - Made-up or non-standard units — using units that don't exist in any CSS specification.
- Missing spaces or operators — accidentally concatenating a number with a keyword, like
100vhmaxinstead of usingmax(100vh, ...). - Using units in the wrong context — some newer or less common units may not yet be recognized by the validator, though all widely supported CSS units should be accepted.
This matters because browsers may silently ignore or misinterpret properties with invalid dimension values, leading to broken layouts. Using valid units ensures consistent rendering across browsers and compliance with CSS standards.
How to Fix
- Check the CSS value flagged in the error message.
- Verify the unit is a valid CSS unit (e.g.,
px,em,rem,%,vw,vh,vmin,vmax,ch,ex,cm,mm,in,pt,pc,s,ms,deg,rad,turn,fr). - Fix any typos, remove extra characters, or replace non-standard units with valid ones.
- If the value is meant to be unitless (like
line-height: 1.5), remove the erroneous unit entirely.
Examples
Incorrect: Misspelled unit
<div style="margin: 10pxl;">Hello</div>
The unit pxl is not a valid CSS unit. The validator reports an unknown dimension for 10pxl.
Correct: Valid unit
<div style="margin: 10px;">Hello</div>
Incorrect: Made-up unit
<style>
.box {
width: 50pixels;
height: 200hv;
}
</style>
Neither pixels nor hv are valid CSS units.
Correct: Standard CSS units
<style>
.box {
width: 50px;
height: 200vh;
}
</style>
Incorrect: Missing space causes concatenation
<style>
.container {
font-size: 1remx;
}
</style>
The extra x turns rem into the unknown dimension remx.
Correct: Proper unit
<style>
.container {
font-size: 1rem;
}
</style>
Incorrect: Unit where none is needed
<style>
p {
line-height: 1.5em2;
}
</style>
Correct: Unitless value or valid unit
<style>
p {
line-height: 1.5;
}
</style>
If you're confident the unit is valid and part of a newer CSS specification (such as container query units like cqi or cqb), the validator may not yet support it. In that case, the warning can be noted but may not indicate an actual problem in modern browsers. However, always double-check for typos first — the most common cause is simply a misspelled unit.
The CSS rgba() function takes the red, green and blue channels as separate numbers, so a hex code or a color name inside it, as in rgba(#1f2937, 0.75), is invalid.
Passing a whole color to rgba() is Sass syntax. Sass has its own rgba() that accepts a color and an alpha value, and the compiler turns rgba(#1f2937, 0.75) into rgba(31, 41, 55, 0.75). CSS has no such form, so when that code sits in a .css file, a <style> element or a style attribute, the browser gets it as written and drops the whole declaration. The element then keeps whatever background, border, shadow or text color earlier rules gave it, which can put light text on a light background. The validator names the property and quotes the argument it rejected. It reports rgb() the same way, and also flags a color keyword such as red or currentcolor in that position.
A compiled Sass file can still contain the error inside a custom property. Sass copies custom property values to the CSS as written, so --overlay: rgba(#1f2937, 0.75); comes out of the compiler unchanged, and the validator reports it under --overlay. Write --overlay: #{rgba(#1f2937, 0.75)}; instead, and Sass computes the value before writing it out.
To fix the CSS directly, convert the hex code to its three channels (#1f2937 is 31, 41, 55) and write rgba(31, 41, 55, 0.75), or rgb(31 41 55 / 0.75) in the space-separated syntax. A hex code can also take the alpha as two extra digits: #1f2937bf is the same color at about 75% opacity. To keep the original hex code, use relative color syntax, rgb(from #1f2937 r g b / 0.75), which current versions of the major browsers support.
Invalid example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Overlay</title>
<style>
.overlay {
background: rgba(#1f2937, 0.75);
color: #fff;
}
</style>
</head>
<body>
<div class="overlay">
<p>Sunset over the harbor</p>
</div>
</body>
</html>
Valid example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Overlay</title>
<style>
.overlay {
background: rgba(31, 41, 55, 0.75);
color: #fff;
}
</style>
</head>
<body>
<div class="overlay">
<p>Sunset over the harbor</p>
</div>
</body>
</html>
Valid example with relative color syntax
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Overlay</title>
<style>
.overlay {
background: rgb(from #1f2937 r g b / 0.75);
color: #fff;
}
</style>
</head>
<body>
<div class="overlay">
<p>Sunset over the harbor</p>
</div>
</body>
</html>
The role attribute lists more than one ARIA role, and browsers use only the first one they recognize.
The value of role is a list of tokens separated by spaces. WAI-ARIA allows the list as a fallback mechanism: the browser reads the tokens from left to right and uses the first one that names a defined, non-abstract ARIA role. Every token after that one is ignored. The validator names the ignored token in the message. When there are several, it lists them all in a single message.
A repeated role, such as role="region region", is the most common cause. Page builders and templates produce it when two pieces of code each add the same role to one element. The browser treats it exactly like role="region", so deleting the copy changes nothing for screen reader users. For this particular role you can also use a <section> with an accessible name, which has the region role without any role attribute.
The other cause is a fallback list written on purpose, such as role="switch checkbox", meant for browsers that don't support the first role. A browser that knows switch never reads checkbox. Keep the one role that describes what the element does and remove the rest. If two different roles both seem to fit, the element is probably doing two jobs, and it's better to split it into two elements.
When the first token isn't a valid role, the validator reports it with a different message, "Discarding unrecognized token", and browsers move on to the next token in the list.
Invalid example
<div role="region region" aria-labelledby="faq-heading">
<h2 id="faq-heading">Frequently asked questions</h2>
<p>Answers to common questions about shipping and returns.</p>
</div>
<button type="button" role="switch checkbox" aria-checked="false">Dark mode</button>
Valid example
<div role="region" aria-labelledby="faq-heading">
<h2 id="faq-heading">Frequently asked questions</h2>
<p>Answers to common questions about shipping and returns.</p>
</div>
<button type="button" role="switch" aria-checked="false">Dark mode</button>
The role attribute contains a token that does not name a defined, non-abstract ARIA role.
A role value can contain a list of tokens separated by spaces. Browsers read the list from left to right and use the first recognized, non-abstract role. They ignore unknown tokens such as initial. Although initial is a CSS keyword, it does not reset an ARIA role.
Remove the unrecognized token and keep the role that describes the element's purpose. In this example, status identifies a message that assistive technologies can announce when it changes. Removing initial preserves that role. If a native HTML element already provides the intended semantics, use it without an unnecessary role attribute.
Invalid example
<div role="initial status">Application received.</div>
Valid example
<div role="status">Application received.</div>
Private Use Area (PUA) characters are reserved ranges in Unicode whose interpretation is not specified by any encoding standard. Their meaning is determined entirely by private agreement between cooperating parties—such as a font vendor and its users. This means that a PUA character that renders as a custom icon in one font may appear as a blank square, a question mark, or a completely different glyph when that specific font is unavailable.
This warning commonly appears when using icon fonts like older versions of Font Awesome, Material Icons, or custom symbol fonts. These fonts map their icons to PUA code points. While this approach works visually when the font loads correctly, it creates several problems:
- Accessibility: Screen readers cannot interpret PUA characters meaningfully. A visually impaired user may hear nothing, hear "private use area character," or hear an unrelated description depending on their assistive technology.
- Portability: If the associated font fails to load (due to network issues, content security policies, or user preferences), the characters become meaningless boxes or blank spaces.
- Interoperability: Copy-pasting text containing PUA characters into another application, email client, or document will likely produce garbled or missing content since the receiving system won't know how to interpret those code points.
- Standards compliance: The W3C and Unicode Consortium both recommend against using PUA characters in publicly exchanged documents for exactly these reasons.
Sometimes PUA characters sneak into your HTML unintentionally—through copy-pasting from word processors, PDFs, or design tools that use custom encodings. Other times, they are inserted deliberately via CSS content properties or HTML entities by icon font libraries.
To fix this, identify where the PUA characters appear and replace them with standard alternatives. Use inline SVG for icons, standard Unicode symbols where appropriate (e.g., ✓ U+2713 instead of a PUA checkmark), or CSS background images. If you must use an icon font, hide the PUA character from assistive technology using aria-hidden="true" and provide an accessible label separately.
Examples
Problematic: PUA character used directly in HTML
<!-- The character below (U+E001) is a PUA code point -->
<p>Status: </p>
Without the specific icon font loaded, PUA characters like U+E001 render as missing glyphs or blank spaces.
Fixed: Using inline SVG with accessible label
<p>
Status:
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16">
<path d="M6 10.8L2.5 7.3 1.1 8.7 6 13.6 14.9 4.7 13.5 3.3z"/>
</svg>
<span>Complete</span>
</p>
Problematic: Icon font via CSS content property
<style>
.icon-check::before {
font-family: "MyIcons";
content: "\e001"; /* PUA character */
}
</style>
<span class="icon-check"></span>
Fixed: Icon font with accessibility safeguards
If you must continue using an icon font, hide the PUA character from assistive technology and provide an accessible alternative:
<style>
.icon-check::before {
font-family: "MyIcons";
content: "\e001";
}
</style>
<span class="icon-check" aria-hidden="true"></span>
<span class="sr-only">Checkmark</span>
Note that this approach still triggers the validator warning if the PUA character is detectable in the markup. The most robust fix is to avoid PUA characters entirely.
Fixed: Using a standard Unicode character
<p>Status: ✓ Complete</p>
The character ✓ (U+2713, CHECK MARK) is a standard Unicode character that is universally understood and renders consistently across platforms.
Problematic: PUA character from copy-paste
<p>Click here to download</p>
Invisible or unexpected PUA characters sometimes hide in text pasted from external sources. Inspect your source code carefully—many code editors can highlight non-ASCII characters or reveal their code points.
Fixed: Cleaned-up text
<p>Click here to download</p>
If you've audited your document and determined that the PUA characters are intentional and rendering correctly in your target environments, you may choose to accept this warning. However, for publicly accessible web pages, replacing PUA characters with standard alternatives is always the safer and more accessible choice.
When an HTML element contains the same attribute more than once, the browser must decide which value to use. According to the WHATWG HTML specification, the parser keeps only the first occurrence and silently discards the rest. This means any values you placed in the second (or subsequent) attribute are completely ignored — often leading to unexpected behavior that can be difficult to debug.
This issue commonly arises in a few scenarios:
- Copy-paste mistakes where code fragments are merged without deduplicating attributes.
- Template or CMS output where multiple systems each inject the same attribute onto an element.
- Attempting to assign multiple values by repeating the attribute instead of combining the values into one (especially common with
classandstyle).
Why this matters
- Unpredictable behavior: Since only the first value is kept, the duplicate is silently dropped. If you intended the second value, your page won't work as expected and there will be no visible error in the browser console.
- Accessibility concerns: Duplicate
idattributes or duplicate ARIA attributes can confuse assistive technologies, breaking navigation and screen reader announcements. - Standards compliance: Duplicate attributes violate the HTML specification and will cause validation errors, which can signal deeper quality issues in your markup.
- Maintainability: Code with duplicate attributes is harder to read and maintain, and it obscures the developer's intent.
Examples
❌ Duplicate class attribute
A common mistake is trying to add multiple classes by repeating the class attribute:
<div class="card" class="highlighted">Content</div>
The browser only applies "card" and ignores "highlighted" entirely.
✅ Merge classes into a single attribute
Combine all class names into one space-separated class attribute:
<div class="card highlighted">Content</div>
❌ Duplicate id attribute
<a id="home-link" id="nav-link">Home</a>
Only "home-link" is used; "nav-link" is discarded.
✅ Use a single id
Choose the appropriate id value. If you need multiple hooks for styling or scripting, use class for the additional identifier:
<a id="home-link" class="nav-link">Home</a>
❌ Duplicate style attribute
<p style="color: red;" style="font-weight: bold;">Important text</p>
Only color: red is applied; the bold style is lost.
✅ Combine styles into one attribute
<p style="color: red; font-weight: bold;">Important text</p>
❌ Duplicate data-* or event attributes
This also applies to data attributes and event handlers:
<button data-action="save" data-action="submit" onclick="handleClick()" onclick="trackEvent()">
Submit
</button>
✅ Use a single value per attribute
<button data-action="submit" onclick="handleClick(); trackEvent();">
Submit
</button>
❌ Duplicate attributes in template output
Templating systems sometimes produce duplicate attributes when multiple directives target the same element:
<input type="text" name="email" placeholder="Enter email" placeholder="you@example.com">
✅ Ensure templates produce a single attribute
Review your template logic so only one value is rendered:
<input type="text" name="email" placeholder="you@example.com">
How to fix it
- Search your markup for the attribute name flagged by the validator. Look for it appearing more than once on the same element.
- Decide which value is correct. If both values are needed, merge them into a single attribute (e.g., space-separated class names, semicolon-separated style declarations).
- Remove the duplicate. Delete the extra occurrence so only one remains.
- Check your build tools and templates. If the duplication comes from a CMS, templating engine, or JavaScript that sets attributes dynamically, fix the source rather than just the output.
- Re-validate your page to confirm the error is resolved.
Within a <dl>, each name should appear in only one <dt>, so a term with several values gets one <dt> followed by several <dd> elements.
A description list is a set of name-value groups, and the HTML specification says a single <dl> should not have more than one <dt> for each name. When the same term shows up twice with different values, readers can't tell whether the second entry replaces the first, adds to it, or is a mistake. Repeated terms often come from lists built from data, such as product specifications where one attribute is output twice.
The validator compares the text content of each <dt>. It ignores markup and leading or trailing whitespace, so <dt><b>Size</b></dt> and <dt> Size </dt> both count as Size. The comparison is case-sensitive, so Size and size are different names. Wrapping each group in a <div> doesn't help, because the check covers the whole <dl>. Along with this warning, the validator adds a second message pointing to the first <dt> with that name.
If both values belong to the same term, keep one <dt> and put each value in its own <dd>. If the entries describe different things that share a label, give each <dt> a distinct name, or move them into separate <dl> elements, since the rule applies only within a single list.
Invalid example
<dl>
<dt>Size</dt>
<dd>Small</dd>
<dt>Color</dt>
<dd>Red</dd>
<dt>Size</dt>
<dd>Medium</dd>
</dl>
Valid example
<dl>
<dt>Size</dt>
<dd>Small</dd>
<dd>Medium</dd>
<dt>Color</dt>
<dd>Red</dd>
</dl>
Valid example with distinct names
<dl>
<dt>Net weight</dt>
<dd>1.2 kg</dd>
<dt>Gross weight</dt>
<dd>1.4 kg</dd>
</dl>
The id attribute serves as a unique identifier for a single element in the DOM. The HTML specification explicitly requires that id values be unique across the entire document. When you reuse an id, you violate this contract, and the consequences can be subtle but far-reaching.
JavaScript behavior becomes unpredictable. Methods like document.getElementById() will only return the first element with a given id, silently ignoring any duplicates. This can cause scripts to target the wrong element or fail to interact with elements you expect them to reach.
CSS selectors may not apply as intended. While most browsers will style all elements with a duplicated id, this behavior is not guaranteed by the specification and can lead to inconsistencies across browsers.
Accessibility is compromised. Screen readers and other assistive technologies rely on unique IDs to associate labels with form controls (via for/id pairing), link aria-describedby or aria-labelledby references to specific elements, and navigate fragment identifiers (anchor links). Duplicate IDs break these associations, potentially making content confusing or unusable for people relying on assistive technology.
Fragment navigation breaks. When a URL contains a hash like #section-intro, the browser scrolls to the element with that id. If multiple elements share the same id, only the first one will be targeted, which may not be the intended destination.
Common causes of duplicate IDs include copy-pasting HTML blocks without updating the id values, dynamically generating content in a loop without appending a unique suffix, and reusing template partials that contain hardcoded id attributes.
To fix this issue, audit your document for repeated id values. If multiple elements need the same identifier for styling purposes, use the class attribute instead. If the id is needed for JavaScript or ARIA references, make each value unique — for example, by appending a number or descriptive suffix.
Examples
❌ Duplicate IDs on multiple elements
<div id="card">
<h2>First Card</h2>
</div>
<div id="card">
<h2>Second Card</h2>
</div>
Both <div> elements share id="card", which triggers the validation error.
✅ Use unique IDs
<div id="card-1">
<h2>First Card</h2>
</div>
<div id="card-2">
<h2>Second Card</h2>
</div>
✅ Use class instead when you don't need unique identification
<div class="card">
<h2>First Card</h2>
</div>
<div class="card">
<h2>Second Card</h2>
</div>
❌ Duplicate IDs break label associations
<label for="email">Work Email</label>
<input type="email" id="email" name="work_email">
<label for="email">Personal Email</label>
<input type="email" id="email" name="personal_email">
Both inputs share id="email", so the second <label> will incorrectly point to the first input. A screen reader user clicking "Personal Email" would be focused on the wrong field.
✅ Unique IDs for each label–input pair
<label for="work-email">Work Email</label>
<input type="email" id="work-email" name="work_email">
<label for="personal-email">Personal Email</label>
<input type="email" id="personal-email" name="personal_email">
❌ Duplicate IDs in dynamically repeated content
This often happens when generating HTML in a loop or reusing a template:
<section id="product">
<h2>Widget A</h2>
</section>
<section id="product">
<h2>Widget B</h2>
</section>
<section id="product">
<h2>Widget C</h2>
</section>
✅ Append a unique suffix
<section id="product-1">
<h2>Widget A</h2>
</section>
<section id="product-2">
<h2>Widget B</h2>
</section>
<section id="product-3">
<h2>Widget C</h2>
</section>
If no element actually needs to be uniquely identified, remove the id entirely and use a class or a data attribute instead.
An <a> element without an href attribute can't use aria-expanded unless it also has a role that supports that state.
Without href, an <a> isn't a link. HTML treats it as a placeholder, and its ARIA role is generic. The aria-expanded attribute only applies to certain roles, such as button, link, tab and menuitem, so on a placeholder anchor it describes a state that screen readers have nothing to attach to. The anchor also can't receive keyboard focus, so keyboard users can't reach the control.
This usually comes from a menu or dropdown toggle written as <a aria-expanded="false"> and wired up with JavaScript. The message also lists aria-checked and aria-level, but adding either of them doesn't fix the element: the validator then asks for href or role instead. Add an href if the element takes the user somewhere. If it opens and closes part of the page, replace it with a <button type="button">, which is focusable, works with the keyboard and supports aria-expanded without extra attributes. Keeping the <a> with role="button" and tabindex="0" also passes validation, but then your script has to handle the Enter and Space keys.
Invalid example
<a class="menu-toggle" aria-expanded="false" aria-controls="account-menu">Account</a>
<ul id="account-menu" hidden>
<li><a href="/profile">Profile</a></li>
<li><a href="/logout">Log out</a></li>
</ul>
Valid example
<button type="button" class="menu-toggle" aria-expanded="false" aria-controls="account-menu">Account</button>
<ul id="account-menu" hidden>
<li><a href="/profile">Profile</a></li>
<li><a href="/logout">Log out</a></li>
</ul>
An <a> element without an href attribute can't use aria-selected unless it also has a role that supports the selected state.
Only four roles support aria-selected: tab, option, row and gridcell. An <a> with an href has the link role, and one without href is a placeholder with the generic role. Neither has a selected state, so the attribute tells assistive technology nothing it can use. An anchor without href also can't receive keyboard focus, which leaves keyboard users unable to reach it.
The error usually comes from tabs or filter buttons built from bare <a> tags, where a script moves aria-selected="true" to the active item. The message also lists aria-checked and href, but adding either one only swaps this error for another: links don't support aria-selected, and aria-checked doesn't stand in for the missing role.
For tabs, give each tab role="tab", wrap the group in a role="tablist" container and point each tab at its role="tabpanel" with aria-controls. A <button type="button"> works better than an <a> here because it's focusable without a tabindex. If the control shows and hides content, use a <button> with aria-expanded. If it marks the current page in a navigation menu, give the link its href and use aria-current="page" instead.
Invalid example
<div class="tabs">
<a aria-selected="true" aria-controls="panel-specs">Specifications</a>
<a aria-selected="false" aria-controls="panel-reviews">Reviews</a>
</div>
<div id="panel-specs">
<p>Weight: 1.2 kg</p>
</div>
<div id="panel-reviews" hidden>
<p>No reviews yet.</p>
</div>
Valid example
<div role="tablist" aria-label="Product details">
<button type="button" role="tab" id="tab-specs" aria-selected="true" aria-controls="panel-specs">Specifications</button>
<button type="button" role="tab" id="tab-reviews" aria-selected="false" aria-controls="panel-reviews" tabindex="-1">Reviews</button>
</div>
<div role="tabpanel" id="panel-specs" aria-labelledby="tab-specs">
<p>Weight: 1.2 kg</p>
</div>
<div role="tabpanel" id="panel-reviews" aria-labelledby="tab-reviews" hidden>
<p>No reviews yet.</p>
</div>
A link (an <a> with an href) has an aria-selected attribute but no role that supports it.
aria-selected only means something on roles such as tab, option, row and gridcell. A link has the link role, which has no selected state, so the attribute has no defined meaning there. The message lists aria-checked next to role, but role is the one that matters: adding aria-checked only changes the error to one that asks for role. Without an href, the message also asks for href.
Often aria-selected is there to mark the current page in a navigation menu. That job belongs to aria-current="page", which works on plain links and needs no role. Put it on the link to the page the user is on, and leave it off the others.
If the links really are tabs that switch between panels on the same page, give each one role="tab", put them inside an element with role="tablist", and point each tab at a role="tabpanel" element. The validator checks those parts too. Tabs also need scripted keyboard support, as the WAI-ARIA tabs pattern describes.
Invalid example
<nav aria-label="Main">
<ul>
<li><a href="/" aria-selected="true">Home</a></li>
<li><a href="/blog/" aria-selected="false">Blog</a></li>
</ul>
</nav>
Valid example
Navigation links mark the current page with aria-current:
<nav aria-label="Main">
<ul>
<li><a href="/" aria-current="page">Home</a></li>
<li><a href="/blog/">Blog</a></li>
</ul>
</nav>
Links that work as tabs get the tab roles:
<div role="tablist" aria-label="Account">
<a href="#profile" role="tab" id="tab-profile" aria-controls="profile" aria-selected="true">Profile</a>
<a href="#billing" role="tab" id="tab-billing" aria-controls="billing" aria-selected="false" tabindex="-1">Billing</a>
</div>
<div id="profile" role="tabpanel" aria-labelledby="tab-profile">Profile settings</div>
<div id="billing" role="tabpanel" aria-labelledby="tab-billing" hidden>Billing settings</div>
According to the HTML specification, the <a> element can exist without an href attribute, but in that case it represents a placeholder where a link might otherwise have been placed. However, the validator flags this as an issue because an <a> element without href and without role is ambiguous — browsers won't treat it as a link (it won't be focusable or keyboard-accessible), and assistive technologies won't know how to present it to users.
This matters for several reasons:
- Accessibility: Without
href, the<a>element loses its implicitrole="link"and is no longer announced as a link by screen readers. It also won't appear in the tab order, making it invisible to keyboard users. - Semantics: If the element is styled and scripted to behave like a button or link but lacks the proper attributes, it creates a disconnect between what users see and what the browser understands.
- Standards compliance: The spec expects you to be explicit about the element's purpose when
hrefis absent.
The most common cause of this issue is using <a> elements as JavaScript-only click targets without providing an href, or using them as styled containers without any interactive purpose.
How to Fix It
There are several approaches depending on your intent:
- Add an
hrefattribute if the element should be a link. This is the most common and recommended fix. - Add a
roleattribute if you're deliberately using<a>withouthreffor a specific purpose, such asrole="button". - Use a different element entirely. If it's not a link, consider using a
<button>,<span>, or another semantically appropriate element.
Examples
❌ Missing both href and role
<a>Click here</a>
This triggers the validator error because the <a> has neither href nor role.
❌ JavaScript-only handler without href
<a onclick="doSomething()">Submit</a>
Even with an event handler, the element lacks href and role, so it fails validation and is inaccessible to keyboard users.
✅ Fix by adding an href
<a href="/about">About us</a>
Adding href makes it a proper hyperlink — focusable, keyboard-accessible, and recognized by screen readers.
✅ Fix by adding role for a non-link purpose
<a role="button" tabindex="0" onclick="doSomething()">Submit</a>
If you must use <a> without href as a button, add role="button" and tabindex="0" to ensure it's focusable and properly announced. However, consider using a real <button> instead.
✅ Better: use the right element
<button type="button" onclick="doSomething()">Submit</button>
If the element triggers an action rather than navigating somewhere, a <button> is the correct semantic choice. It's focusable by default, responds to keyboard events, and doesn't need extra attributes.
✅ Placeholder anchor (intentional non-link)
<a role="link" aria-disabled="true">Coming soon</a>
If you're intentionally showing a placeholder where a link will eventually appear, you can add a role and indicate its disabled state for assistive technologies. Alternatively, use a <span> with appropriate styling to avoid the issue altogether.
The HTML specification defines <button> as a versatile interactive element, but its behavior changes depending on context. When a <button> is placed inside a <form> without a type attribute, it defaults to type="submit", which can cause unexpected form submissions. The validator flags this because relying on the implicit default is ambiguous and error-prone. Explicitly setting the type attribute makes the button's intent clear to both developers and browsers.
The three valid values for the type attribute are:
submit— submits the parent form's data to the server.reset— resets all form controls to their initial values.button— performs no default action; behavior is defined via JavaScript.
When a <button> is given an ARIA role of checkbox, switch, or menuitemcheckbox, the validator expects an aria-checked attribute to accompany it. These roles describe toggle controls that have a checked or unchecked state, so assistive technologies need to know the current state. Without aria-checked, screen readers cannot communicate whether the control is on or off, making the interface inaccessible.
The aria-checked attribute accepts the following values:
true— the control is checked or on.false— the control is unchecked or off.mixed— the control is in an indeterminate state (valid forcheckboxandmenuitemcheckboxroles only).
How to fix it
For standard buttons, add the type attribute with the appropriate value. If the button triggers JavaScript behavior and is not meant to submit a form, use type="button". If it submits a form, use type="submit" explicitly to make the intent clear.
For toggle buttons, ensure the <button> has both a role attribute (such as checkbox or switch) and an aria-checked attribute that reflects the current state. You should also include type="button" to prevent unintended form submission. Use JavaScript to toggle the aria-checked value when the user interacts with the button.
Examples
Missing type attribute
This triggers the validator warning because the type is not specified:
<form action="/search">
<input type="text" name="q">
<button>Search</button>
</form>
Fixed by adding an explicit type:
<form action="/search">
<input type="text" name="q">
<button type="submit">Search</button>
</form>
Button used outside a form without type
<button onclick="openMenu()">Menu</button>
Fixed by specifying type="button":
<button type="button" onclick="openMenu()">Menu</button>
Toggle button missing aria-checked
A button with role="switch" but no aria-checked attribute:
<button type="button" role="switch">Dark Mode</button>
Fixed by adding aria-checked:
<button type="button" role="switch" aria-checked="false">Dark Mode</button>
Checkbox-style toggle button
A button acting as a checkbox must include both role="checkbox" and aria-checked:
<button type="button" role="checkbox" aria-checked="false">
Enable notifications
</button>
Complete toggle example with all required attributes
<button type="button" role="switch" aria-checked="false" id="wifi-toggle">
Wi-Fi
</button>
<script>
document.getElementById("wifi-toggle").addEventListener("click", function () {
const isChecked = this.getAttribute("aria-checked") === "true";
this.setAttribute("aria-checked", String(!isChecked));
});
</script>
In this example, the type="button" prevents form submission, the role="switch" tells assistive technologies this is a toggle, and aria-checked is updated dynamically to reflect the current state. This ensures the button is fully accessible and passes validation.
A <button> with role="combobox" needs an aria-expanded attribute, and the validator reports this message when the button doesn't have one.
Custom select menus often use a <button> as a combobox. Clicking it opens a popup, usually an element with role="listbox", where the user picks a value. ARIA requires aria-expanded on every combobox so screen readers can announce whether that popup is open. Start with false in the markup, then have your script set it to true when the list opens and back to false when it closes.
The message also lists type, but type on its own won't clear it: add only type="button" and the validator reports that aria-expanded is required instead. Keep type="button" anyway, since a <button> inside a form submits that form by default.
A button that already has aria-expanded can still trigger this message if it also carries an aria-activedescendant written with no value, as in <button aria-activedescendant role="combobox" aria-expanded="false">. Depending on the order of the attributes, the validator reports this message instead of flagging the empty value. The value of aria-activedescendant has to be the id of the option that currently has focus, so leave the attribute out of the markup until an option is active.
Invalid example
<button role="combobox" aria-controls="sort-options" aria-label="Sort by">
Newest first
</button>
<ul id="sort-options" role="listbox" hidden>
<li id="sort-newest" role="option" aria-selected="true">Newest first</li>
<li id="sort-oldest" role="option" aria-selected="false">Oldest first</li>
</ul>
Valid example
<button type="button" role="combobox" aria-expanded="false" aria-controls="sort-options" aria-label="Sort by">
Newest first
</button>
<ul id="sort-options" role="listbox" hidden>
<li id="sort-newest" role="option" aria-selected="true">Newest first</li>
<li id="sort-oldest" role="option" aria-selected="false">Oldest first</li>
</ul>
The first child of a <details> element must be a <summary>, and this error means the validator found something else there, or nothing at all.
The <summary> is the visible label of the disclosure widget, the part people click or tab to when they want to open or close the rest of the content. If it's missing, browsers make up a label of their own, usually "Details" in the browser's language. That tells sighted users and screen reader users nothing about what's inside.
A <summary> only counts when it comes first. Comments and whitespace before it are fine, but any element or text pushes it out of place. A <summary> after a paragraph, or wrapped in a <div>, leaves the <details> without one, and the validator adds a second error for the misplaced element: Element “summary” not allowed as child of element “details” in this context. (or … child of element “div” …). A second <summary> in the same <details> gets that error too.
Sometimes <details> ends up as a plain wrapper, for example around anchor targets or layout blocks, when nobody meant to build a collapsible section. In that case, replace it with a <div> or <section>. Otherwise, add a short <summary> as the first child, or move the existing one to the top.
Invalid example
<details>
<p>Orders ship within two business days.</p>
</details>
<details>
<p>Unused items can be returned within 30 days.</p>
<summary>Returns</summary>
</details>
Valid example
<details>
<summary>Shipping</summary>
<p>Orders ship within two business days.</p>
</details>
<details>
<summary>Returns</summary>
<p>Unused items can be returned within 30 days.</p>
</details>
The <dl> element represents a description list — a collection of terms (<dt>) paired with their descriptions (<dd>). According to the HTML specification, the permitted content of a <dl> is either groups of <dt> and <dd> elements directly, or <div> elements that wrap those groups. This <div> wrapping option exists specifically to help with styling, since it lets you apply CSS to a term-description pair as a unit.
However, these wrapper <div> elements are not general-purpose containers inside <dl>. The spec requires that each <div> inside a <dl> contains at least one <dt> or <dd> child. A <div> that is empty, or that contains other elements like <span>, <p>, or another <div>, violates this rule and produces a validation error.
This matters for several reasons. Screen readers and assistive technologies rely on the semantic structure of description lists to convey the relationship between terms and definitions. An empty or improperly structured <div> inside a <dl> breaks that semantic contract, potentially confusing both assistive technology and browsers. Keeping your markup valid also ensures consistent rendering across all browsers.
How to Fix It
- Ensure every
<div>inside a<dl>contains at least one<dt>or<dd>— don't leave wrapper<div>elements empty. - Don't put non-
<dt>/<dd>content directly inside these<div>wrappers — elements like<span>,<p>, or nested<div>elements should be placed inside a<dt>or<dd>, not as siblings to them. - Remove unnecessary
<div>wrappers — if a<div>inside a<dl>serves no styling or grouping purpose, remove it entirely.
Examples
❌ Empty <div> inside a <dl>
<dl>
<div>
</div>
<div>
<dt>HTML</dt>
<dd>A markup language for structuring web content.</dd>
</div>
</dl>
The first <div> is empty and has no <dt> or <dd> child, triggering the error.
❌ <div> with only non-<dt>/<dd> children
<dl>
<div>
<p>This is a description list:</p>
</div>
<div>
<dt>CSS</dt>
<dd>A style sheet language for describing presentation.</dd>
</div>
</dl>
The first <div> contains a <p> element but no <dt> or <dd>, which is invalid.
✅ Each <div> contains <dt> and <dd> elements
<dl>
<div>
<dt>HTML</dt>
<dd>A markup language for structuring web content.</dd>
</div>
<div>
<dt>CSS</dt>
<dd>A style sheet language for describing presentation.</dd>
</div>
</dl>
✅ Using <dl> without <div> wrappers
If you don't need <div> elements for styling, you can place <dt> and <dd> directly inside the <dl>:
<dl>
<dt>HTML</dt>
<dd>A markup language for structuring web content.</dd>
<dt>CSS</dt>
<dd>A style sheet language for describing presentation.</dd>
</dl>
✅ A <dt> with multiple <dd> descriptions in a <div>
A single term can have multiple descriptions. The <div> is valid as long as it contains at least one <dt> or <dd>:
<dl>
<div>
<dt>JavaScript</dt>
<dd>A programming language for the web.</dd>
<dd>Supports event-driven and functional programming.</dd>
</div>
</dl>
The aria-expanded attribute cannot be used on a plain div element without also specifying a role attribute.
The aria-expanded attribute indicates whether a grouping of content that the element owns or controls is currently expanded or collapsed. However, this attribute is only valid on elements that have an appropriate implicit or explicit role. A plain div has no implicit ARIA role, so you must assign one explicitly.
The aria-expanded attribute is commonly used with interactive roles such as button, combobox, treeitem, or link. Adding the correct role tells assistive technologies what kind of element the user is interacting with, making aria-expanded meaningful in context.
HTML Examples
❌ Invalid: aria-expanded on a plain div
<div aria-expanded="false">
Menu content
</div>
✅ Valid: aria-expanded with an appropriate role
<div role="button" aria-expanded="false">
Menu content
</div>
Alternatively, consider using a native HTML element that already carries the correct semantics, which avoids the need for a role attribute entirely:
<button aria-expanded="false">
Toggle Menu
</button>
Using a native <button> is generally preferred over <div role="button"> because it comes with built-in keyboard interaction and focus behavior.
The aria-required attribute tells assistive technologies that a form field must be filled in before the form can be submitted. However, this attribute is only valid on elements that function as interactive widgets. A bare div has no implicit ARIA role, so assistive technologies have no context for what kind of input is expected. The validator flags this because an aria-required attribute on a generic div is effectively meaningless without additional ARIA attributes that define the element's role and behavior.
This matters for several reasons:
- Accessibility: Screen readers and other assistive technologies rely on roles to understand how to present an element to users. Without a role,
aria-requiredprovides incomplete information. - Standards compliance: The WAI-ARIA specification defines which attributes are allowed on which roles. Using
aria-requiredwithout an established role violates these constraints. - Browser behavior: Browsers may ignore or misinterpret ARIA attributes when they appear on elements that lack the proper role context.
How to fix it
Option 1: Use native semantic HTML (preferred)
Whenever possible, use native HTML form elements. They come with built-in accessibility semantics, keyboard interaction, and validation — no ARIA needed.
Replace a div with aria-required="true" with an appropriate form control using the native required attribute:
<input type="text" required>
<select required>
<option value="">Choose one</option>
<option value="1">Option 1</option>
</select>
<textarea required></textarea>
Option 2: Add an appropriate role attribute
When you must use a div as a custom widget (styled and enhanced with CSS and JavaScript), add the correct role attribute to give it semantic meaning. Choose the role that matches the widget's actual behavior — don't just pick one arbitrarily.
Common roles that support aria-required:
combobox— a custom dropdown with text inputlistbox— a custom selection listradiogroup— a group of radio-like optionsspinbutton— a numeric stepper (also requiresaria-valuemax,aria-valuemin, andaria-valuenow)textbox— a custom text input
Option 3: Add other qualifying ARIA attributes
For certain widgets like sliders or spinbuttons, you may need aria-valuemax, aria-valuemin, and aria-valuenow in addition to (or as part of) defining the role. These attributes inherently establish a widget context.
Examples
❌ Invalid: aria-required on a plain div
<div aria-required="true">
<div data-value="One">1</div>
<div data-value="Two">2</div>
<div data-value="Three">3</div>
</div>
This triggers the validation error because the div has no role or other ARIA attributes to define what kind of widget it is.
✅ Fixed: Adding the appropriate role
<div aria-required="true" role="radiogroup" aria-label="Pick a number">
<div role="radio" aria-checked="false" tabindex="0">1</div>
<div role="radio" aria-checked="false" tabindex="0">2</div>
<div role="radio" aria-checked="false" tabindex="0">3</div>
</div>
Adding role="radiogroup" gives the div a semantic identity. Note that child elements also need appropriate roles and attributes for the widget to be fully accessible.
✅ Fixed: Using native HTML instead
<fieldset>
<legend>Pick a number</legend>
<label><input type="radio" name="number" value="1" required> 1</label>
<label><input type="radio" name="number" value="2"> 2</label>
<label><input type="radio" name="number" value="3"> 3</label>
</fieldset>
This approach uses native radio buttons with the required attribute, eliminating the need for ARIA entirely. The browser handles accessibility, keyboard navigation, and form validation automatically.
✅ Fixed: A custom spinbutton with value attributes
<div role="spinbutton"
aria-required="true"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow="50"
aria-label="Quantity"
tabindex="0">
50
</div>
For a spinbutton role, you must also provide aria-valuemin, aria-valuemax, and aria-valuenow to fully describe the widget's state.
The HTML specification defines a strict content model for the <ul> (unordered list) element: its permitted content is zero or more <li> elements, optionally intermixed with <script> and <template> elements. A <div> is not among these allowed children, so placing one directly inside a <ul> produces a validation error.
This issue commonly arises when developers try to group or wrap list items for styling or layout purposes. For example, you might want to add a container around certain <li> elements for flexbox or grid alignment, or you might be using a templating system that injects wrapper <div> elements into your list markup.
Why this matters
- Browser parsing inconsistencies: When browsers encounter invalid nesting, they attempt to fix the DOM structure automatically, but different browsers may handle it differently. This can lead to unexpected rendering where list items appear outside their intended container or styles break unpredictably.
- Accessibility: Screen readers and assistive technologies rely on correct semantic structure to convey list relationships to users. A
<div>breaking the<ul>→<li>relationship can cause assistive tools to misinterpret or skip list content entirely. - Standards compliance: Invalid HTML can cause cascading parser errors — note that the validator message says "Suppressing further errors from this subtree," meaning additional issues within that structure may be hidden from you.
How to fix it
- Move the
<div>inside the<li>: If you need a wrapper for styling, place it inside the list item rather than around it. - Remove the
<div>entirely: If it serves no purpose, simply remove it and let the<li>elements sit directly inside the<ul>. - Use CSS on the
<li>elements: In many cases, you can apply the styles you need directly to the<li>elements without an extra wrapper. - Use
role="list"on a<div>parent: If your layout truly requires<div>wrappers, consider restructuring with ARIA roles, though native semantic elements are always preferred.
Examples
❌ Incorrect: <div> as a direct child of <ul>
<ul>
<div>
<li>Apples</li>
<li>Bananas</li>
</div>
<div>
<li>Carrots</li>
<li>Dates</li>
</div>
</ul>
✅ Correct: Move the <div> inside each <li>
<ul>
<li><div>Apples</div></li>
<li><div>Bananas</div></li>
<li><div>Carrots</div></li>
<li><div>Dates</div></li>
</ul>
✅ Correct: Remove the <div> entirely
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Carrots</li>
<li>Dates</li>
</ul>
❌ Incorrect: Using a <div> as a styling wrapper around list items
<ul class="product-list">
<div class="row">
<li>Product A</li>
<li>Product B</li>
<li>Product C</li>
</div>
</ul>
✅ Correct: Apply layout styles directly to the <ul> and <li> elements
<ul class="product-list row">
<li>Product A</li>
<li>Product B</li>
<li>Product C</li>
</ul>
❌ Incorrect: Template or component wrapper inserting a <div>
This often happens in frameworks where a component renders a wrapping <div>:
<ul>
<div class="list-item-wrapper">
<li>Item 1</li>
</div>
<div class="list-item-wrapper">
<li>Item 2</li>
</div>
</ul>
✅ Correct: Move the wrapper class to the <li> itself
<ul>
<li class="list-item-wrapper">Item 1</li>
<li class="list-item-wrapper">Item 2</li>
</ul>
The same rule applies to <ol> (ordered list) elements — they share the same content model restriction. Always ensure that <li> is the direct child of <ul> or <ol>, and place any additional wrapper elements inside the <li> rather than around it.
According to the HTML specification, the <dl> element's content model requires one or more groups, where each group consists of one or more <dt> elements followed by one or more <dd> elements. Alternatively, these groups can be wrapped in <div> elements for styling purposes. An empty <dl> or one missing either side of the pairing is invalid.
This matters for several reasons. Screen readers and other assistive technologies rely on the proper structure of description lists to convey the relationship between terms and their descriptions. When the structure is incomplete, these tools cannot communicate the intended meaning to users. Browsers may also render malformed description lists inconsistently, leading to unpredictable layouts.
To fix this issue, make sure every <dl> contains at least one <dt> element paired with at least one <dd> element. If you only have a <dd>, add the corresponding <dt>. If you only have a <dt>, add the corresponding <dd>. If the list is empty or you don't have content for both parts, consider whether a <dl> is the right element for your use case—a <ul> or <p> might be more appropriate.
Examples
Missing <dt> element
A <dd> without its corresponding <dt> triggers this error:
<dl>
<dd>A box without hinges, key, or lid, yet golden treasure inside is hid.</dd>
</dl>
Add the missing <dt> to complete the group:
<dl>
<dt>Egg</dt>
<dd>A box without hinges, key, or lid, yet golden treasure inside is hid.</dd>
</dl>
Missing <dd> element
A <dt> without a following <dd> also triggers this error:
<dl>
<dt>Egg</dt>
</dl>
Add the missing <dd> to provide the description:
<dl>
<dt>Egg</dt>
<dd>A box without hinges, key, or lid, yet golden treasure inside is hid.</dd>
</dl>
Empty <dl> element
An empty description list is invalid:
<dl></dl>
Either populate it with a complete term-description group or remove the element entirely.
Multiple terms and descriptions
A single <dt> can have multiple <dd> elements, and multiple <dt> elements can share the same <dd>. Both are valid:
<dl>
<dt>Egg</dt>
<dt>Ova</dt>
<dd>A box without hinges, key, or lid, yet golden treasure inside is hid.</dd>
<dd>An oval body laid by birds, reptiles, and other creatures.</dd>
</dl>
Using <div> wrappers
You can wrap each name-value group in a <div> for styling purposes, but each <div> must still contain the required <dt> and <dd> pairing:
<dl>
<div>
<dt>Egg</dt>
<dd>A box without hinges, key, or lid, yet golden treasure inside is hid.</dd>
</div>
<div>
<dt>Sun</dt>
<dd>An eye in a blue face saw an eye in a green face.</dd>
</div>
</dl>
The <dl> element represents a description list — a collection of name-value groups where <dt> elements provide the terms (or names) and <dd> elements provide the associated descriptions (or values). According to the HTML specification, the content model for <dl> requires that each <dt> group be followed by one or more <dd> elements. A <dl> with only <dt> elements and no <dd> elements is invalid HTML.
This matters for several reasons. Assistive technologies like screen readers rely on the proper <dt>/<dd> pairing to convey the relationship between terms and their descriptions. A description list without descriptions is semantically meaningless — it's like having a dictionary with words but no definitions. Browsers may also render the list inconsistently when the expected structure is incomplete.
Common causes of this error include:
- Accidentally using
<dl>and<dt>to create a simple list instead of using<ul>or<ol>. - Dynamically generated content where the
<dd>elements are missing due to empty data. - Incomplete markup where the developer forgot to add the description elements.
To fix this issue, make sure every <dt> element inside a <dl> is followed by at least one <dd> element. If you don't actually need a description list, consider using a different element like <ul> for simple lists.
Examples
Invalid: <dl> with only <dt> and no <dd>
<dl>
<dt>The Meaning of Life</dt>
</dl>
This is invalid because the <dt> term has no corresponding <dd> description.
Fixed: Adding a <dd> element
<dl>
<dt>The Meaning of Life</dt>
<dd>A philosophical question about the significance of existence.</dd>
</dl>
Invalid: Multiple terms without any descriptions
<dl>
<dt>HTML</dt>
<dt>CSS</dt>
<dt>JavaScript</dt>
</dl>
This triggers the error because none of the terms have associated descriptions.
Fixed: Each term with a description
<dl>
<dt>HTML</dt>
<dd>A markup language for structuring web content.</dd>
<dt>CSS</dt>
<dd>A style sheet language for describing presentation.</dd>
<dt>JavaScript</dt>
<dd>A programming language for web interactivity.</dd>
</dl>
Valid: Multiple terms sharing a single description
Multiple <dt> elements can share a single <dd>, which is useful for synonyms or aliases:
<dl>
<dt>Laptop</dt>
<dt>Notebook</dt>
<dd>A portable personal computer with a clamshell form factor.</dd>
</dl>
Valid: A single term with multiple descriptions
A <dt> can also be followed by multiple <dd> elements:
<dl>
<dt>Python</dt>
<dd>A large constricting snake.</dd>
<dd>A high-level programming language.</dd>
</dl>
Valid: Using <div> to wrap name-value groups
The HTML spec allows wrapping each <dt>/<dd> group in a <div> for styling purposes. Each <div> must still contain at least one <dd>:
<dl>
<div>
<dt>Name</dt>
<dd>Jane Doe</dd>
</div>
<div>
<dt>Email</dt>
<dd>jane@example.com</dd>
</div>
</dl>
Alternative: Use <ul> when descriptions aren't needed
If you only need a list of items without descriptions, a <dl> is the wrong element. Use an unordered list instead:
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
The <title> element is a required child of <head> according to the HTML specification. It defines the document's title, which appears in the browser tab, is used as the default name when bookmarking the page, and is displayed as the clickable heading in search engine results. Omitting it violates the HTML standard and triggers this validation error.
Beyond standards compliance, the <title> element is critical for accessibility. Screen readers announce the page title when a user navigates to a new page or switches between tabs, giving them immediate context about where they are. A missing title forces assistive technology users to explore the page content to understand its purpose. Search engines also rely heavily on the <title> for indexing and ranking, so omitting it can hurt discoverability.
There are several common causes for this error:
- The
<title>element is simply missing. This often happens in boilerplate code or quick prototypes where it's overlooked. - Duplicate
<head>sections. If your HTML contains two<head>elements (for example, from a copy-paste error or a templating mistake), the validator may flag the second one as missing a<title>. - The
<title>is placed outside<head>. If the<title>element accidentally ends up in the<body>or before the<head>, the validator won't count it as a child of<head>. - The
<title>is empty. While an empty<title>element (<title></title>) may not trigger this specific error, some validators will flag it separately. Always include descriptive text.
Examples
Missing <title> element
This triggers the validation error because the <head> has no <title>:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
<title> placed outside <head>
Here the <title> exists but is in the wrong location, so the <head> is still considered to be missing it:
<!DOCTYPE html>
<html lang="en">
<title>My Page</title>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
Duplicate <head> sections
A templating error or copy-paste mistake can introduce a second <head>, which lacks its own <title>:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
Correct usage
Place a single <title> element with descriptive text inside the <head>:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome — My Website</title>
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
Tips for a good <title>
- Keep it concise but descriptive — aim for roughly 50–60 characters.
- Make it unique for each page on your site. Avoid generic titles like "Untitled" or "Page".
- Front-load the most important information. For example,
Contact Us — My Companyis more useful thanMy Company — Contact Uswhen users scan many browser tabs. - Avoid duplicating the
<h1>verbatim; the title should provide broader context (such as including the site name), while the<h1>focuses on page-specific content.
Every <hgroup> must contain one heading element, from <h1> to <h6>, as a direct child, and this <hgroup> has none.
<hgroup> pairs a heading with related text, such as a subtitle, a tagline or a chapter number. It holds exactly one heading, with optional <p> elements before or after it. Script-supporting elements like <script> and <template> are allowed too.
This error usually appears when <hgroup> is used as a styling wrapper, for example around a logo link in the page header, or when every line inside it is a <p>. A heading wrapped in a <div> or <a> doesn't count, because it has to be a direct child. Any element that isn't allowed inside <hgroup> also gets its own error, such as Element “a” not allowed as child of element “hgroup” in this context.
If the content isn't a heading with a subtitle, replace the <hgroup> with a <div> or remove it. If it is, mark the title up as a heading and keep the extra lines in <p> elements. Older versions of the spec let <hgroup> hold several headings, but now it takes only one, so a subtitle written as <h2> belongs in a <p>.
Invalid example
<header>
<hgroup>
<a href="/">
<img src="logo.png" alt="Example Shop">
</a>
</hgroup>
</header>
<hgroup>
<p>Chapter 3</p>
<p>The long way home</p>
</hgroup>
Valid example
<header>
<a href="/">
<img src="logo.png" alt="Example Shop">
</a>
</header>
<hgroup>
<p>Chapter 3</p>
<h1>The long way home</h1>
</hgroup>
Every <img> element must include at least a src or a srcset attribute to be valid HTML.
The <img> element exists to embed an image into the document, and it needs to know where that image is. The src attribute provides a single URL for the image, while srcset lets you offer multiple image sources for different screen sizes or resolutions.
You might run into this error when using JavaScript to set the image source dynamically, or when using lazy-loading libraries that store the URL in a data- attribute like data-src. While those techniques work at runtime, they produce invalid HTML because the validator still expects src or srcset to be present in the markup.
If you genuinely don't have a source yet, you can use a placeholder or a transparent pixel as the src value.
Invalid Example
<img alt="A cute cat" loading="lazy" data-src="cat.jpg">
Valid Examples
Using src:
<img src="cat.jpg" alt="A cute cat">
Using srcset:
<img srcset="cat-400.jpg 400w, cat-800.jpg 800w"
sizes="(max-width: 600px) 400px, 800px"
alt="A cute cat">
Using both src and a lazy-loading data-src (keeps the markup valid while still supporting lazy loading):
<img src="placeholder.jpg" data-src="cat.jpg" alt="A cute cat">
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