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.
This message points to the first <dt> in a <dl> whose name is repeated later in the same list.
It always comes with a duplicate dt name warning on the later <dt>. Together, the two messages show where each copy of the term is, so you can compare them and decide which one to keep. The HTML specification says a single <dl> should not have more than one <dt> for each name.
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> have the same name. The comparison is case-sensitive, so Size and size don't clash.
The first <dt> is usually fine on its own; the fix goes where the name repeats. If both entries describe the same term, keep one <dt> and give each value its own <dd>. If they describe different things, give each <dt> a distinct name. Once every name in the list is unique, both messages go away.
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>
The HTML specification requires that every id attribute value must be unique within a document. When the validator encounters the same id on two or more elements, it raises an error on the second (and subsequent) occurrences, along with a companion message — "The first occurrence of ID 'X' was here" — pointing to the original element. This companion message helps you quickly compare both locations and decide which one to rename or remove.
Why Duplicate IDs Are a Problem
Accessibility: Screen readers and other assistive technologies rely on unique IDs to associate <label> elements with form controls, to navigate ARIA relationships like aria-labelledby and aria-describedby, and to jump to page landmarks. When IDs are duplicated, these associations break, leaving users confused or unable to interact with the page properly.
JavaScript behavior: Methods like document.getElementById() return only the first matching element. If you intend to target the second element with a duplicated ID, your code will silently operate on the wrong one. This can lead to bugs that are difficult to track down.
CSS specificity: While #my-id selectors will style all elements with that ID in most browsers, this is non-standard behavior. Relying on it leads to fragile, unpredictable styling.
Fragment navigation: Links using href="#section" scroll to the first element with that ID. Duplicate IDs make it impossible to link to the second occurrence.
How to Fix It
- Identify the duplicates. The validator tells you the line number of the first occurrence and the line number of the duplicate. Compare both elements.
- Rename one of the IDs to something unique and descriptive. Update any corresponding references (labels, ARIA attributes, JavaScript selectors, CSS rules, and anchor links).
- Use
classinstead ofidwhen you need to apply the same style or behavior to multiple elements. Classes are designed to be reused; IDs are not.
Examples
❌ Duplicate IDs trigger the error
<div id="product-card">
<h2>Widget A</h2>
<p>A useful widget.</p>
</div>
<div id="product-card">
<h2>Widget B</h2>
<p>Another useful widget.</p>
</div>
The validator will report an error on the second div and display the message "The first occurrence of ID 'product-card' was here" pointing to the first div.
✅ Fixed: Give each element a unique ID
<div id="product-card-a">
<h2>Widget A</h2>
<p>A useful widget.</p>
</div>
<div id="product-card-b">
<h2>Widget B</h2>
<p>Another useful widget.</p>
</div>
✅ Fixed: Use a class for shared styling or behavior
If both elements don't need to be individually targeted, replace the id with a class:
<div class="product-card">
<h2>Widget A</h2>
<p>A useful widget.</p>
</div>
<div class="product-card">
<h2>Widget B</h2>
<p>Another useful widget.</p>
</div>
❌ Duplicate IDs breaking a label association
<label for="email">Email</label>
<input type="email" id="email" name="primary-email">
<label for="email">Backup Email</label>
<input type="email" id="email" name="backup-email">
Both labels point to for="email", but only the first input will be associated. The second label effectively has a broken link.
✅ Fixed: Unique IDs for each form control
<label for="primary-email">Email</label>
<input type="email" id="primary-email" name="primary-email">
<label for="backup-email">Backup Email</label>
<input type="email" id="backup-email" name="backup-email">
Now each <label> correctly associates with its own <input>, and both assistive technologies and JavaScript can target each field reliably.
A required <select> drop-down must start with a placeholder <option> whose value is empty, so the browser can tell when the user hasn't picked anything.
A <select> with no multiple attribute and no size greater than 1 renders as a drop-down, and the browser selects its first option by default. For required to block an untouched drop-down, that first option has to mean "no choice yet". HTML calls it the placeholder label option, and it only counts as one when its value is the empty string.
An option's value is its value attribute or, if it has none, its text. Both <option value="none">Select a topic</option> and <option>Select a topic</option> have a non-empty value, so the browser accepts the prompt as a real answer. The form submits even if the user never opens the drop-down, and the server receives none or Select a topic as the chosen topic.
Give the first option value="" and keep the prompt as its text. An empty <option></option> also passes this check, but the validator then asks for a label attribute, so a text prompt is simpler. If you want a list box that shows every option at once instead of a drop-down, set size to the number of options, and the validator stops asking for a placeholder.
Invalid example
<label for="topic">Topic</label>
<select id="topic" name="topic" required>
<option value="none">Select a topic</option>
<option value="billing">Billing</option>
<option value="support">Technical support</option>
</select>
Valid example
<label for="topic">Topic</label>
<select id="topic" name="topic" required>
<option value="">Select a topic</option>
<option value="billing">Billing</option>
<option value="support">Technical support</option>
</select>
The <font> element was originally introduced to give authors control over text rendering directly in markup. A typical usage looked like <font face="Arial" size="3" color="red">. While browsers still render this element for backward compatibility, it has been obsolete since HTML5 and will trigger a validation error. The W3C validator flags it because it violates the principle of separation of concerns: HTML should define the structure and meaning of content, while CSS should handle its visual presentation.
Using <font> causes several practical problems:
- Maintainability: Styling scattered across
<font>tags throughout your HTML is extremely difficult to update. Changing a color scheme could mean editing hundreds of elements instead of a single CSS rule. - Accessibility: The
<font>element carries no semantic meaning. Screen readers and other assistive technologies gain nothing from it, and its presence can clutter the document structure. - Consistency: CSS enables you to define styles in one place and apply them uniformly across your entire site using classes, selectors, or external stylesheets.
- Standards compliance: Using obsolete elements means your HTML does not conform to the current specification, which can lead to unexpected rendering in future browser versions.
To fix this issue, remove every <font> element and replace its visual effects with equivalent CSS properties. The three attributes of <font> map directly to CSS:
<font> attribute | CSS equivalent |
|---|---|
color | color |
size | font-size |
face | font-family |
You can apply CSS as inline styles for quick fixes, but using a <style> block or an external stylesheet with classes is the preferred approach for any real project.
Examples
Incorrect: using the obsolete <font> element
<p>
<font face="Arial" size="4" color="blue">Welcome to my website</font>
</p>
This triggers the validator error: The "font" element is obsolete. Use CSS instead.
Fix with inline styles
If you need a quick, direct replacement:
<p style="font-family: Arial, sans-serif; font-size: 18px; color: blue;">
Welcome to my website
</p>
Fix with a CSS class (recommended)
Using a class keeps your HTML clean and makes styles reusable:
<style>
.welcome-text {
font-family: Arial, sans-serif;
font-size: 18px;
color: blue;
}
</style>
<p class="welcome-text">Welcome to my website</p>
Nested <font> elements replaced with CSS
Old markup sometimes used multiple nested <font> tags:
<!-- Obsolete -->
<p>
<font color="red" size="5">
Important:
<font face="Courier">code goes here</font>
</font>
</p>
The correct approach uses <span> elements or semantic tags with CSS classes:
<style>
.alert-heading {
color: red;
font-size: 24px;
}
.code-snippet {
font-family: Courier, monospace;
}
</style>
<p>
<span class="alert-heading">
Important:
<span class="code-snippet">code goes here</span>
</span>
</p>
If the text carries a specific meaning — such as marking something as important or representing code — consider using semantic HTML elements like <strong>, <em>, or <code> alongside your CSS:
<style>
.alert-heading {
color: red;
font-size: 24px;
}
</style>
<p class="alert-heading">
<strong>Important:</strong>
<code>code goes here</code>
</p>
This approach gives you full control over appearance through CSS while keeping your HTML meaningful, accessible, and standards-compliant.
Many HTML elements come with built-in (implicit) ARIA roles that browsers and assistive technologies already recognize. The <form> element natively maps to the form ARIA role, meaning screen readers and other tools already understand it as a form landmark without any extra attributes. When you explicitly add role="form" to a <form> element, you're telling the browser something it already knows.
This redundancy is problematic for several reasons:
- Code clarity: Unnecessary attributes make your HTML harder to read and maintain. Other developers may wonder if the explicit role is there to override something or if it serves a special purpose.
- Misleading intent: Explicit ARIA roles are typically reserved for cases where you need to override or supplement the default semantics of an element. Using them unnecessarily can signal to future maintainers that something unusual is happening when it isn't.
- ARIA best practices: The first rule of ARIA is "do not use ARIA if you can use a native HTML element or attribute with the semantics and behavior you require." Adding redundant ARIA roles goes against this principle.
It's worth noting that the <form> element's implicit form role only exposes it as a landmark when the form has an accessible name (e.g., via aria-label or aria-labelledby). If you need your form to appear as a landmark region, provide an accessible name rather than adding a redundant role.
To fix this issue, simply remove role="form" from any <form> element. If you want the form to function as a named landmark for assistive technology users, add an accessible name instead.
Examples
❌ Incorrect: redundant role="form"
<form role="form" action="/subscribe" method="post">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Subscribe</button>
</form>
This triggers the validator warning because role="form" duplicates the element's implicit role.
✅ Correct: no explicit role
<form action="/subscribe" method="post">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Subscribe</button>
</form>
The <form> element already communicates its role natively. No ARIA attribute is needed.
✅ Correct: form with an accessible name for landmark navigation
<form action="/subscribe" method="post" aria-label="Newsletter subscription">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Subscribe</button>
</form>
If you want the form to be discoverable as a named landmark by screen reader users, provide an aria-label or aria-labelledby attribute — not a redundant role.
Other elements with implicit roles
The same principle applies to many other HTML elements. Avoid adding redundant roles like these:
<!-- ❌ Redundant roles -->
<nav role="navigation">...</nav>
<main role="main">...</main>
<header role="banner">...</header>
<footer role="contentinfo">...</footer>
<button role="button">Click me</button>
<!-- ✅ Let native semantics do the work -->
<nav>...</nav>
<main>...</main>
<header>...</header>
<footer>...</footer>
<button>Click me</button>
Trust the native semantics of HTML elements. Only use explicit ARIA roles when you genuinely need to change or supplement an element's default behavior.
The <frame> element is obsolete, so the content each frame loads has to move into the page itself or into an <iframe> inside a normal <body>.
A <frame> only works inside a <frameset>, where it loads a separate HTML file into one pane of the browser window. The validator reports this message once for every <frame> on the page, and the <frameset> around them gets a message of its own. Moving the frames into a <body> doesn't help: the parser drops a <frame> there and reports it as a stray start tag. The frames and the frameset have to be replaced together, and when the frameset only wraps another site in a single frame, an HTTP redirect to that site replaces both.
What replaces each frame depends on what it holds. A header or menu that every page shares belongs in the page itself, written directly or pulled in with a server-side include or a template, so it lives at the same URL as the content around it. A document that has to stay separate can load in an <iframe>. Iframes take src and name just as frames did, so links with a matching target keep loading into them, and the validator stops warning that name is never allowed on <frame>. Give each iframe a title describing what it shows, since screen readers announce it.
The presentation attributes of a frame don't carry over. On an <iframe>, frameborder, scrolling, marginwidth and marginheight are obsolete too, and the validator warns about each one. Remove the border with border: 0 in CSS. Scrollbars and margins belong to the document loaded inside, so set overflow and margin in that document's own stylesheet. noresize needs no replacement, since an iframe has no draggable border between panes.
Invalid example
A header frame above a catalog frame:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Garden supplies</title>
</head>
<frameset rows="80,*">
<frame src="header.html" scrolling="no" noresize frameborder="0">
<frame src="catalog.html" frameborder="0">
</frameset>
</html>
Valid example
The header is part of the page (on a real site it would come from an include), and the catalog keeps loading from its own file in an iframe:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Garden supplies</title>
<style>
iframe {
width: 100%;
height: 80vh;
border: 0;
}
</style>
</head>
<body>
<header>
<a href="/">Garden supplies</a>
</header>
<iframe src="catalog.html" name="catalog" title="Product catalog"></iframe>
</body>
</html>
The <frameset> element is obsolete, so a page split into frames has to become a normal page with a <body>, using CSS for the layout and <iframe> or server-side includes for the shared parts.
A frameset document has a <frameset> where the <body> would go, and each <frame> inside it loads a separate HTML file into one pane of the window. The HTML standard lists <frameset>, <frame> and <noframes> as obsolete. Browsers still render framesets so old sites keep working, but the validator reports the <frameset> once and then each <frame> and <noframes> with a message of its own. The rows and cols attributes go away with the element and aren't reported separately.
Frames cause trouble beyond validation. The address bar keeps showing the frameset's URL whatever is loaded inside it, so a visitor can't bookmark or share a specific page, and search engines can send people straight to a framed page without the navigation that was meant to surround it.
The fix depends on what the frames were for. When they hold shared navigation, the usual answer is one complete page per URL, with the navigation pulled in on the server through an include, a template or a static site generator. When a pane really has to load other documents, an <iframe> inside a regular <body> does that job, sized with CSS and given a title so screen readers can announce it. A frameset with a single frame that fills the window, such as rows="100%,*", is often the "masked forwarding" a domain registrar sets up to show another site under a different domain. In that case, replace it with an HTTP 301 redirect to the real site.
Invalid example
A manual with a table of contents on the left and the chapter on the right:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Product manual</title>
</head>
<frameset cols="25%,75%">
<frame src="contents.html">
<frame src="chapter-1.html">
</frameset>
</html>
Valid example
The table of contents moves into the page, and an <iframe> loads each chapter that its links target:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Product manual</title>
<link rel="stylesheet" href="manual.css">
</head>
<body>
<nav>
<ul>
<li><a href="chapter-1.html" target="chapter">Chapter 1</a></li>
<li><a href="chapter-2.html" target="chapter">Chapter 2</a></li>
</ul>
</nav>
<iframe src="chapter-1.html" name="chapter" title="Chapter text"></iframe>
</body>
</html>
body {
display: flex;
height: 100vh;
margin: 0;
}
nav {
flex: 0 0 25%;
}
iframe {
flex: 1;
border: 0;
}
The iframe keeps the two-pane layout, but every chapter still shares one URL. Publishing each chapter as its own page, with the table of contents included on the server, gives every chapter an address people can bookmark and link to.
The <gcse:search> element is a custom tag from Google's Programmable Search Engine widget and is not part of any HTML specification.
Google's Programmable Search Engine (formerly Custom Search Engine) offers two ways to drop a search box onto a page. The older one uses namespaced tags such as <gcse:search>, <gcse:searchbox>, and <gcse:searchresults>, which the loaded cse.js script finds and replaces with the real widget. Browsers do not recognize the gcse: prefix, so they treat the tag as an unknown element, and the W3C validator rejects it because no such element exists in HTML.
Google supports an equivalent form that is valid HTML: a standard <div> carrying a gcse- class, like <div class="gcse-search">. The script reads the class instead of a custom tag name and renders the same search box. Switching to the class form clears the validation error without changing how the widget works.
HTML examples
Invalid: namespaced <gcse:search> element
<script async src="https://cse.google.com/cse.js?cx=YOUR_SEARCH_ENGINE_ID"></script>
<gcse:search></gcse:search>
Valid: div with the gcse-search class
<script async src="https://cse.google.com/cse.js?cx=YOUR_SEARCH_ENGINE_ID"></script>
<div class="gcse-search"></div>
The same applies to the other Programmable Search tags: replace <gcse:searchbox> with <div class="gcse-searchbox"></div> and <gcse:searchresults> with <div class="gcse-searchresults"></div>. Each gcse: element has a matching gcse- class that produces the same result and passes validation.
Many HTML elements come with built-in ARIA roles that assistive technologies already recognize. The <fieldset> element is one of these — its implicit role is group, which tells screen readers that the contained form controls are related. When you add role="group" to a <fieldset>, you're telling the browser something it already knows.
This redundancy matters for a few reasons:
- Code cleanliness: Unnecessary attributes add clutter, making your markup harder to read and maintain.
- ARIA best practices: The first rule of ARIA is "If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so." Adding
role="group"to<fieldset>violates this principle in spirit — it suggests the developer may not understand the element's native semantics. - Potential confusion: Explicitly setting roles that match the default can mislead other developers into thinking the role is doing something special, or that removing it would change behavior.
This same principle applies to other elements with implicit roles, such as role="navigation" on <nav>, role="banner" on <header>, or role="button" on <button>. If the element already carries the semantic meaning natively, there's no need to duplicate it with an explicit ARIA role.
To fix this, simply remove the role="group" attribute from the <fieldset> element. No replacement is needed — the browser and assistive technologies will continue to treat the <fieldset> as a group automatically.
Examples
Incorrect: redundant role="group" on <fieldset>
<form>
<fieldset role="group">
<legend>Shipping Address</legend>
<label for="street">Street:</label>
<input type="text" id="street" name="street">
<label for="city">City:</label>
<input type="text" id="city" name="city">
</fieldset>
</form>
The validator will report that the group role is unnecessary for the <fieldset> element.
Correct: <fieldset> without explicit role
<form>
<fieldset>
<legend>Shipping Address</legend>
<label for="street">Street:</label>
<input type="text" id="street" name="street">
<label for="city">City:</label>
<input type="text" id="city" name="city">
</fieldset>
</form>
The <fieldset> element inherently communicates the group role to assistive technologies, so no ARIA attribute is needed.
When role on <fieldset> is appropriate
There are cases where you might legitimately set a different role on a <fieldset> — for example, role="radiogroup" when the fieldset contains a set of related radio buttons and you want to convey more specific semantics:
<form>
<fieldset role="radiogroup" aria-labelledby="color-legend">
<legend id="color-legend">Favorite Color</legend>
<label><input type="radio" name="color" value="red"> Red</label>
<label><input type="radio" name="color" value="blue"> Blue</label>
<label><input type="radio" name="color" value="green"> Green</label>
</fieldset>
</form>
This is valid because radiogroup is a different role that provides more specific meaning than the default group. The validator only warns when the explicit role matches the element's implicit role.
An image's usemap attribute points to a <map> by name, and the page has no <map> whose name matches the text after the #.
The value of usemap is a hash-name reference: a # followed by the name of a <map> element in the same document. The <area> elements inside that map define the clickable regions of the image, so usemap="#floor-plan" needs a <map name="floor-plan"> somewhere on the page.
The validator compares the two values exactly, so <map name="Floor-Plan"> doesn't match. A name that repeats the # (name="#floor-plan") doesn't match either, because the # belongs only in usemap. And a <map> with only id="floor-plan" won't do: name is required on <map>, and the validator reports its absence as a separate error.
If the page has no matching map at all, browsers show a plain image with no clickable regions, and visitors never see the links the map was supposed to provide. This often happens when an image is copied from another page, or inserted by a CMS, without the <map> that went with it.
Add the missing <map>, or fix the existing map's name so it matches the usemap value character for character. If the image doesn't need clickable regions, remove the usemap attribute instead.
Invalid example
<img src="floor-plan.png" alt="Office floor plan" width="400" height="300" usemap="#floor-plan">
<map name="Floor-Plan">
<area shape="rect" coords="0,0,200,300" href="/rooms/kitchen" alt="Kitchen">
<area shape="rect" coords="200,0,400,300" href="/rooms/meeting-room" alt="Meeting room">
</map>
Valid example
<img src="floor-plan.png" alt="Office floor plan" width="400" height="300" usemap="#floor-plan">
<map name="floor-plan">
<area shape="rect" coords="0,0,200,300" href="/rooms/kitchen" alt="Kitchen">
<area shape="rect" coords="200,0,400,300" href="/rooms/meeting-room" alt="Meeting room">
</map>
The headers attribute creates explicit associations between data cells (td) and header cells (th) in complex tables. This is especially important for tables with irregular structures—such as those with merged cells or multiple header levels—where the browser cannot automatically determine which headers apply to which data cells.
When the validator reports this error, it means one or more IDs referenced in a td's headers attribute cannot be matched to any th element with that id in the same table. Common causes include:
- Typos — A small misspelling in either the
headersvalue or thethelement'sid. - Missing
id— Thethelement exists but doesn't have anidattribute assigned. - Removed or renamed headers — The
thwas deleted or itsidwas changed during refactoring, but thetdstill references the old value. - Cross-table references — The
thwith the referencedidexists in a different<table>, which is not allowed.
Why this matters
This issue directly impacts accessibility. Screen readers use the headers attribute to announce which header cells are associated with a data cell. When a referenced ID doesn't resolve to a th in the same table, assistive technology cannot provide this context, making the table confusing or unusable for users who rely on it. Broken headers references also indicate invalid HTML according to the WHATWG HTML specification, which requires that each token in the headers attribute match the id of a th cell in the same table.
How to fix it
- Locate the
tdelement flagged by the validator and note the ID it references. - Search the same
<table>for athelement with a matchingid. - If the
thexists but has noidor a differentid, add or correct theidattribute so it matches. - If the
thwas removed, either restore it or remove theheadersattribute from thetd. - Double-check for case sensitivity — HTML
idvalues are case-sensitive, soheaders="Name"does not matchid="name".
Examples
Incorrect: headers references a non-existent ID
The first td references "product", but no th has id="product". The second th has id="cost", but the second td references "price" — a mismatch.
<table>
<tr>
<th>Product</th>
<th id="cost">Price</th>
</tr>
<tr>
<td headers="product">Widget</td>
<td headers="price">$9.99</td>
</tr>
</table>
Correct: each headers value matches a th with the same id
<table>
<tr>
<th id="product">Product</th>
<th id="cost">Price</th>
</tr>
<tr>
<td headers="product">Widget</td>
<td headers="cost">$9.99</td>
</tr>
</table>
Correct: multiple headers on a single td
In complex tables, a data cell may relate to more than one header. List multiple IDs separated by spaces — each one must correspond to a th in the same table.
<table>
<tr>
<th id="region" rowspan="2">Region</th>
<th id="q1" colspan="2">Q1</th>
</tr>
<tr>
<th id="sales">Sales</th>
<th id="returns">Returns</th>
</tr>
<tr>
<td headers="region">North</td>
<td headers="q1 sales">1200</td>
<td headers="q1 returns">45</td>
</tr>
</table>
Tip: simple tables may not need headers at all
For straightforward tables with a single row of column headers, browsers and screen readers can infer the associations automatically. In those cases, you can omit the headers attribute entirely and avoid this class of error:
<table>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td>Widget</td>
<td>$9.99</td>
</tr>
</table>
Reserve the headers attribute for complex tables where automatic association is insufficient — such as tables with cells that span multiple rows or columns, or tables with headers in both rows and columns.
Every ID in the headers attribute of a th has to be the id of another th in the same table, and the validator flags each one that isn't.
On a header cell, headers ties a sub-header to the header cells above it or beside it. When a "Sales" header spans the "Q1" and "Q2" columns, <th headers="sales">Q1</th> says that Q1 belongs to Sales. The value is a space-separated list of IDs, and the validator checks each one on its own, so a single cell can trigger this message more than once.
The referenced header is usually where things went wrong. The validator reports the ID when:
- the group header has no
id, or a different one (IDs are case-sensitive, soSalesdoesn't matchsales) - the
idsits on atdstyled to look like a heading, or on thetr, thetheador aspaninside theth, instead of on thethitself - the
thwith thatidbelongs to another table, like a nested table or a separate table used as a fixed header row
Screen readers rely on these references to tell users which headers a cell falls under. When an ID doesn't resolve to a th, the sub-header loses its link to the group. Put the id on the group header's th, changing a td into a th if needed. If that header no longer exists, remove its ID from headers.
The standard also forbids a header cell that targets itself, either directly or through a chain of other headers' headers attributes. The validator doesn't report that loop, so check for it yourself when header cells point at each other.
Invalid example
<table>
<tr>
<td id="sales" colspan="2">Sales</td>
</tr>
<tr>
<th headers="sales">Q1</th>
<th headers="sales">Q2</th>
</tr>
<tr>
<td>1200</td>
<td>1350</td>
</tr>
</table>
Valid example
<table>
<tr>
<th id="sales" colspan="2">Sales</th>
</tr>
<tr>
<th headers="sales">Q1</th>
<th headers="sales">Q2</th>
</tr>
<tr>
<td>1200</td>
<td>1350</td>
</tr>
</table>
HTML heading elements (<h1> through <h6>) have built-in semantic meaning that browsers and assistive technologies already understand. According to the WAI-ARIA specification, each of these elements carries an implicit heading role with a corresponding aria-level — <h1> has aria-level="1", <h2> has aria-level="2", and so on. When you explicitly add role="heading" to one of these elements, you're telling the browser something it already knows, which clutters your markup without providing any benefit.
This pattern is part of a broader principle in ARIA authoring known as the first rule of ARIA: don't use ARIA when a native HTML element already provides the semantics you need. Redundant ARIA roles can cause confusion for developers maintaining the code, as it suggests that the role might be necessary or that the element might not otherwise be recognized as a heading. In some edge cases, adding an explicit aria-level that doesn't match the heading level (e.g., aria-level="3" on an <h1>) can create conflicting information for screen readers, leading to an inconsistent experience for users of assistive technologies.
The role="heading" attribute is designed for situations where you need to give heading semantics to a non-heading element, such as a <div> or <span>. In those cases, you must also include the aria-level attribute to specify the heading's level. However, whenever possible, using native heading elements is always preferred over this ARIA-based approach.
How to fix it
- Remove
role="heading"from any<h1>through<h6>element. - Remove
aria-levelif it was added alongside the redundant role and matches the heading's native level. - If you genuinely need a non-standard element to act as a heading, use
role="heading"witharia-levelon that element instead — but prefer native heading elements whenever possible.
Examples
❌ Redundant role on a native heading
<h1 role="heading" aria-level="1">Welcome to My Site</h1>
<h2 role="heading">About Us</h2>
<h3 role="heading" aria-level="3">Our Mission</h3>
All three headings will trigger the validator warning. The role="heading" and aria-level attributes are completely unnecessary here because the elements already convey this information natively.
✅ Native headings without redundant roles
<h1>Welcome to My Site</h1>
<h2>About Us</h2>
<h3>Our Mission</h3>
Simply removing the redundant attributes resolves the issue while preserving full accessibility.
✅ Correct use of the heading role on a non-heading element
In rare cases where you cannot use a native heading element, the heading role is appropriate on a generic element:
<div role="heading" aria-level="2">Section Title</div>
This tells assistive technologies to treat the <div> as a level-2 heading. Note that aria-level is required here since a <div> has no implicit heading level. That said, using a native <h2> is always the better choice:
<h2>Section Title</h2>
❌ Conflicting aria-level on a native heading
Be especially careful with this anti-pattern, where the explicit level contradicts the element:
<h1 role="heading" aria-level="3">Page Title</h1>
This sends mixed signals — the element is an <h1> but claims to be level 3. Screen readers may behave unpredictably. If you need a level-3 heading, use <h3>:
<h3>Page Title</h3>
A heading level has been skipped in the document's heading hierarchy, such as jumping from an <h2> directly to an <h4>.
HTML headings (<h1> through <h6>) form a hierarchical outline of the document. Screen readers and other assistive technologies use this hierarchy to help users navigate content. When a level is skipped, the outline becomes ambiguous: does the <h4> after an <h2> belong to a missing <h3> section, or is it a direct subsection of the <h2>? Users who navigate by heading level may assume content is missing.
The rule is straightforward: after an <h1>, the next heading should be <h2>. After an <h2>, use <h3>, and so on. You can go back up the hierarchy at any time (an <h2> after an <h4> is fine, because it starts a new section), but you should not skip down.
If you are using a heading level purely for its visual size, use CSS instead. Apply the correct semantic heading level and style it however you want.
Example with skipped heading level
<h1>Recipe book</h1>
<h2>Desserts</h2>
<h4>Chocolate cake</h4>
The jump from <h2> to <h4> skips the <h3> level.
Fixed heading hierarchy
<h1>Recipe book</h1>
<h2>Desserts</h2>
<h3>Chocolate cake</h3>
If the <h4> was chosen for its smaller font size, apply CSS to the <h3> instead:
<style>
.small-heading {
font-size: 1rem;
}
</style>
<h1>Recipe book</h1>
<h2>Desserts</h2>
<h3 class="small-heading">Chocolate cake</h3>
The <icon> element does not exist in HTML. No version of the HTML specification defines it, and browsers do not recognize it.
This error appears when markup includes <icon> as if it were a standard HTML element. It is not. Browsers will treat it as an unknown inline element with no default behavior or semantics. To display icons, use an <img> element, an <svg> element, or a <span> with CSS-applied background images or icon fonts.
If the intent is to define a favicon (the small icon shown in browser tabs), the correct approach is a <link> element inside <head> with rel="icon".
HTML examples
Invalid: using the <icon> element
<head>
<title>My page</title>
<icon src="favicon.png"></icon>
</head>
Valid: using a <link> element for a favicon
<head>
<title>My page</title>
<link rel="icon" href="favicon.png" type="image/png">
</head>
Valid: displaying an icon inline with <img>
<p>
<img src="star.svg" alt="Star" width="16" height="16"> Favorite
</p>
Valid: displaying an icon inline with <span> and CSS
<p>
<span class="icon icon-star" aria-hidden="true"></span> Favorite
</p>
Every HTML element has an implicit ARIA role defined by the HTML specification. The <img> element's implicit role is img, which means assistive technologies like screen readers already recognize it as an image without any additional ARIA attributes. Adding role="img" explicitly doesn't change behavior — it just adds unnecessary noise to your markup and signals that the author may not understand how native semantics work.
The W3C validator flags this because it violates the first rule of ARIA: don't use ARIA if you can use a native HTML element or attribute that already has the semantics you need. Redundant roles clutter your code, make maintenance harder, and can confuse other developers into thinking the role is there for a specific reason.
The role="img" attribute is genuinely useful in other contexts — for example, when you want to group multiple elements together and have them treated as a single image by assistive technologies. A <div> or <span> has no implicit img role, so adding role="img" to a container is meaningful and appropriate.
How to fix it
Simply remove the role="img" attribute from any <img> element. The image semantics are already built in. Make sure you still provide a meaningful alt attribute for accessibility.
Examples
❌ Redundant role on <img>
<img src="photo.jpg" alt="A sunset over the ocean" role="img">
The validator will warn: The "img" role is unnecessary for element "img".
✅ Fixed: Remove the redundant role
<img src="photo.jpg" alt="A sunset over the ocean">
No explicit role is needed. The browser already communicates this element as an image.
✅ Legitimate use of role="img" on a non-image element
The role="img" attribute is appropriate when applied to a container that groups multiple elements into a single conceptual image:
<div role="img" aria-label="Star rating: 4 out of 5">
<span>⭐</span>
<span>⭐</span>
<span>⭐</span>
<span>⭐</span>
<span>☆</span>
</div>
Here, the <div> has no inherent image semantics, so role="img" is meaningful — it tells assistive technologies to treat the entire group as a single image described by the aria-label.
✅ Another legitimate use: CSS background image with role="img"
<div role="img" aria-label="Company logo" class="logo-background"></div>
Since a <div> styled with a CSS background image has no image semantics, role="img" paired with aria-label ensures the visual content is accessible.
The inputmode attribute is a global attribute that can be applied to any element that is editable, including <input> elements and elements with contenteditable. It tells the browser which type of virtual keyboard to present—for example, a numeric keypad, a telephone dialpad, or a URL-optimized keyboard. This is particularly useful on mobile devices where the on-screen keyboard can be tailored to the expected input.
The W3C validator raises this as an informational warning, not an error. The inputmode attribute is part of the WHATWG HTML Living Standard and is valid HTML. However, the validator flags it because browser support, while now quite broad, has historically been inconsistent. Older versions of Safari, Firefox, and some less common browsers lacked support for certain inputmode values. When inputmode is not recognized, the browser simply ignores it and shows the default keyboard—so it degrades gracefully and won't break your page.
The valid values for inputmode are:
none— No virtual keyboard; useful when the page provides its own input interface.text— Standard text keyboard (the default).decimal— Numeric keyboard with a decimal separator, ideal for fractional numbers.numeric— Numeric keyboard without a decimal separator, ideal for PINs or zip codes.tel— Telephone keypad layout with digits 0–9,*, and#.search— A keyboard optimized for search input, which may include a "Search" or "Go" button.email— A keyboard optimized for email entry, typically including@and.prominently.url— A keyboard optimized for URL entry, typically including/and.com.
It's important to understand the difference between inputmode and the type attribute. The type attribute on <input> defines the semantics and validation behavior of the field (e.g., type="email" validates that the value looks like an email address). The inputmode attribute only affects the virtual keyboard hint and has no impact on validation or semantics. This makes inputmode especially useful when you need a specific keyboard but the field type doesn't match—for example, a numeric PIN field that should remain type="text" to avoid the spinner controls that come with type="number".
How to fix it
Since this is a warning rather than an error, no fix is strictly required. However, you should:
- Test on your target browsers and devices to confirm the virtual keyboard behaves as expected.
- Pair
inputmodewith the appropriatetypeandpatternattributes to ensure proper validation and semantics, sinceinputmodealone does not enforce any input constraints. - Accept graceful degradation — in browsers that don't support
inputmode, users will simply see the default keyboard, which is still functional.
There is no widely adopted polyfill for inputmode because it controls a browser-native UI feature (the virtual keyboard) that JavaScript cannot directly replicate. The best strategy is to treat it as a progressive enhancement.
Examples
Using inputmode for a numeric PIN field
This example triggers the validator warning. The code is valid, but the validator advises caution:
<label for="pin">Enter your PIN:</label>
<input id="pin" type="text" inputmode="numeric" pattern="[0-9]*">
Here, type="text" keeps the field free of number-spinner controls, inputmode="numeric" requests a numeric keypad on mobile, and pattern="[0-9]*" provides client-side validation. This combination is the recommended approach for PIN or verification code fields.
Using inputmode for a currency amount
<label for="amount">Amount ($):</label>
<input id="amount" type="text" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,2}">
The decimal value displays a numeric keyboard that includes a decimal point, which is ideal for monetary values.
Falling back to type when inputmode is unnecessary
If the semantic input type already provides the correct keyboard, you don't need inputmode at all:
<label for="email">Email address:</label>
<input id="email" type="email">
<label for="phone">Phone number:</label>
<input id="phone" type="tel">
<label for="website">Website:</label>
<input id="website" type="url">
Using the appropriate type gives you both the optimized keyboard and built-in browser validation, making inputmode redundant in these cases.
Using inputmode on a contenteditable element
The inputmode attribute also works on non-input elements that accept user input:
<div contenteditable="true" inputmode="numeric">
Enter a number here
</div>
This is one scenario where inputmode is especially valuable, since contenteditable elements don't have a type attribute to influence the keyboard.
Microdata is an HTML specification that lets you embed machine-readable data into your content using three main attributes: itemscope, itemtype, and itemprop. The itemscope attribute creates a new item (a group of name-value pairs), itemtype specifies what kind of thing the item is (using a vocabulary URL like Schema.org), and itemprop defines individual properties within that item. These attributes work together — itemprop only makes sense in the context of an itemscope.
When the validator encounters an itemprop attribute on an element that isn't a descendant of any element with itemscope, it has no way to associate that property with an item. The property is essentially orphaned. This is a problem for several reasons:
- Search engines can't use the data. Structured data consumers like Google, Bing, and other crawlers rely on the
itemscope/itemprophierarchy to understand your content. An orphaneditempropis ignored or misinterpreted. - Standards compliance. The WHATWG HTML living standard requires that an element with
itempropmust be a property of an item — meaning it must have an ancestor withitemscope, or be explicitly referenced via theitemrefattribute on anitemscopeelement. - Maintenance issues. Orphaned
itempropattributes suggest that surrounding markup was refactored and the microdata structure was accidentally broken.
The most common causes of this error are:
- Missing
itemscope— You addeditempropattributes but forgot to define the containing item withitemscope. - Moved elements — An element with
itempropwas moved outside of its originalitemscopecontainer during a refactor. - Copy-paste errors — You copied a snippet that included
itempropbut not the parentitemscope.
To fix the issue, either wrap the itemprop elements inside an itemscope container, use itemref to associate distant properties with an item, or remove the itemprop attribute if structured data is not intended.
Examples
Incorrect: itemprop without itemscope
This triggers the validation error because there is no itemscope ancestor:
<div>
<p>My name is <span itemprop="name">Liza</span>.</p>
</div>
Correct: itemprop inside an itemscope container
Adding itemscope (and optionally itemtype) to an ancestor element fixes the issue:
<div itemscope itemtype="https://schema.org/Person">
<p>My name is <span itemprop="name">Liza</span>.</p>
</div>
Correct: nested items with their own scope
When an item contains a sub-item, the nested item needs its own itemscope:
<div itemscope itemtype="https://schema.org/Person">
<p itemprop="name">Liza</p>
<div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">
<span itemprop="addressLocality">Portland</span>,
<span itemprop="addressRegion">OR</span>
</div>
</div>
Correct: using itemref for properties outside the scope
If you can't restructure your HTML to nest itemprop inside itemscope, use itemref to reference elements by their id:
<div itemscope itemtype="https://schema.org/Person" itemref="user-name"></div>
<p id="user-name">
My name is <span itemprop="name">Liza</span>.
</p>
In this case, the itemprop="name" element is not a descendant of the itemscope element, but the itemref="user-name" attribute explicitly pulls the referenced element's tree into the item, making it valid.
Incorrect: scope broken after refactoring
A common real-world scenario where the error appears after restructuring:
<div itemscope itemtype="https://schema.org/Product">
<span itemprop="name">Widget</span>
</div>
<!-- This was moved out of the div above -->
<span itemprop="price">9.99</span>
Fix this by either moving the element back inside the itemscope container, using itemref, or removing the orphaned itemprop.
The itemtype and itemscope attributes are part of the HTML Microdata specification, which allows you to embed structured, machine-readable data into your HTML. The itemscope attribute creates a new item — it defines a scope within which properties (via itemprop) are associated. The itemtype attribute then specifies a vocabulary URL (typically from Schema.org) that describes what kind of item it is.
According to the WHATWG HTML Living Standard, itemtype has no meaning without itemscope. The itemscope attribute is what establishes the element as a microdata item container. Without it, itemtype has nothing to qualify — there is no item to assign a type to. This is why the spec requires itemscope to be present whenever itemtype is used.
Getting this wrong matters for several reasons:
- Structured data won't work. Search engines like Google rely on valid microdata to generate rich results (e.g., star ratings, event details, product prices). Invalid markup means your structured data will be silently ignored.
- Standards compliance. Using
itemtypewithoutitemscopeviolates the HTML specification, and validators will flag it as an error. - Maintainability. Other developers (or your future self) may assume the microdata is functioning correctly when it isn't.
To fix this issue, you have two options:
- Add
itemscopeto the element — this is the correct fix if you intend to use microdata. - Remove
itemtype— this is appropriate if you don't actually need structured data on that element.
Examples
Incorrect — itemtype without itemscope
This triggers the validation error because itemscope is missing:
<div itemtype="https://schema.org/Person">
<p><span itemprop="name">Liza Jane</span></p>
<p><span itemprop="email">liza.jane@example.com</span></p>
</div>
Correct — adding itemscope alongside itemtype
Adding the itemscope attribute establishes the element as a microdata item, making itemtype valid:
<div itemscope itemtype="https://schema.org/Person">
<p><span itemprop="name">Liza Jane</span></p>
<p><span itemprop="email">liza.jane@example.com</span></p>
</div>
Here, itemscope tells parsers that this div contains a microdata item, and itemtype="https://schema.org/Person" specifies that the item is a Person with properties like name and email.
Correct — removing itemtype when structured data isn't needed
If you don't need typed structured data, simply remove the itemtype attribute. You can still use itemscope on its own to create an untyped item, or remove both attributes entirely:
<div>
<p><span>Liza Jane</span></p>
<p><span>liza.jane@example.com</span></p>
</div>
Correct — nested items with itemscope and itemtype
When nesting microdata items, each level that uses itemtype must also have itemscope:
<div itemscope itemtype="https://schema.org/Organization">
<span itemprop="name">Acme Corp</span>
<div itemprop="founder" itemscope itemtype="https://schema.org/Person">
<span itemprop="name">Liza Jane</span>
</div>
</div>
Notice that both the outer div (the Organization) and the inner div (the Person) have itemscope paired with their respective itemtype values. Omitting itemscope from either element would trigger the validation error.
The HTML specification defines the <label> element as a caption for a single form control. When you place multiple labelable elements inside one <label>, the browser cannot determine which control the label text is associated with. This creates ambiguity for assistive technologies like screen readers, which rely on a clear one-to-one relationship between labels and their controls to announce form fields correctly. It also breaks the click-to-focus behavior — clicking the label text should focus or activate the associated control, but with multiple controls nested inside, the intended target is unclear.
Labelable elements are specifically: <button>, <input> (except type="hidden"), <meter>, <output>, <progress>, <select>, and <textarea>. If any combination of two or more of these appears as descendants of a single <label>, the validator will flag the error.
A common scenario that triggers this is when developers try to group related fields — like a first name and last name — inside one label, or when they nest a button alongside an input within a label for styling convenience.
How to Fix It
- Use one
<label>per control. Wrap each labelable element in its own<label>, or use theforattribute to associate a<label>with a specific control'sid. - Use a container element for grouping. If you need to visually group related controls, use a
<fieldset>with a<legend>instead of a single<label>.
Examples
❌ Incorrect: Two inputs inside one label
<label>
Name
<input type="text" name="first" placeholder="First">
<input type="text" name="last" placeholder="Last">
</label>
This is invalid because the <label> contains two <input> descendants.
✅ Fixed: Separate labels for each input
<label for="first">First name</label>
<input type="text" id="first" name="first">
<label for="last">Last name</label>
<input type="text" id="last" name="last">
✅ Fixed: Using a fieldset to group related controls
<fieldset>
<legend>Name</legend>
<label>
First
<input type="text" name="first">
</label>
<label>
Last
<input type="text" name="last">
</label>
</fieldset>
❌ Incorrect: A select and a button inside one label
<label>
Pick your age
<select name="age">
<option>Young</option>
<option>Old</option>
</select>
<button type="button">Help</button>
</label>
✅ Fixed: Button moved outside the label
<label>
Pick your age
<select name="age">
<option>Young</option>
<option>Old</option>
</select>
</label>
<button type="button">Help</button>
✅ Correct: One control inside a label (implicit association)
<label>
Age
<select id="age" name="age">
<option>Young</option>
<option>Old</option>
</select>
</label>
This is valid because the <label> contains exactly one labelable descendant — the <select> element. The association between the label text and the control is implicit and clear to both browsers and assistive technologies.
The language attribute on the <script> element has been obsolete since HTML4 and should be removed.
Early versions of HTML used language="JavaScript" to specify the scripting language. Modern HTML defaults to JavaScript, so neither language nor type is required in most cases. The type attribute replaced language long ago, but even type="text/javascript" is unnecessary now because all browsers treat scripts as JavaScript by default.
If you do need to specify a non-JavaScript type (such as type="module" or type="application/json"), use the type attribute. Otherwise, omit both attributes entirely.
Examples
Invalid: using the obsolete language attribute
<script language="JavaScript">
console.log("Hello");
</script>
Valid: no attribute needed for plain JavaScript
<script>
console.log("Hello");
</script>
Valid: using type when a specific type is needed
<script type="module">
import { greet } from "./greet.js";
greet();
</script>
The language attribute was used in early HTML to specify the scripting language of a <script> block, typically set to values like "JavaScript" or "VBScript". It was deprecated in HTML 4.01 (in favor of the type attribute) and is now fully obsolete in the HTML Living Standard. While browsers still recognize it for backward compatibility, it serves no functional purpose and triggers a validation warning.
The <script> element accepts several standard attributes, but the two most common are type and src. The type attribute specifies the MIME type or module type of the script (e.g., "module" or "application/json"), and src points to an external script file. When writing standard JavaScript, you can omit type entirely because "text/javascript" is the default. The language attribute, however, should always be removed — it is not a valid substitute for type and has no effect in modern browsers.
Why this matters
- Standards compliance: Using obsolete attributes means your HTML does not conform to the current HTML specification. This can cause validation errors that obscure more important issues in your markup.
- Code clarity: The
languageattribute is misleading to developers who may not realize it's non-functional. Removing it keeps your code clean and easier to maintain. - Future-proofing: While browsers currently tolerate the attribute, there is no guarantee they will continue to do so indefinitely. Relying on obsolete features is a maintenance risk.
How to fix it
Simply remove the language attribute from your <script> elements. If you're using JavaScript (the vast majority of cases), no replacement is needed. If you need to specify a non-default type, use the type attribute instead.
Examples
❌ Obsolete: using the language attribute
<script language="JavaScript">
console.log("Hello, world!");
</script>
<script language="JavaScript" src="app.js"></script>
✅ Fixed: attribute removed
For inline JavaScript, simply omit the attribute:
<script>
console.log("Hello, world!");
</script>
For external scripts, only src is needed:
<script src="app.js"></script>
✅ Using the type attribute when needed
If you need to specify a script type — for example, an ES module or a data block — use the standard type attribute:
<script type="module" src="app.js"></script>
<script type="application/json">
{ "key": "value" }
</script>
Note that type="text/javascript" is valid but redundant, since JavaScript is the default. You can safely omit it for standard scripts.
The <a> element with an href attribute is one of HTML's most fundamental interactive elements. Browsers and assistive technologies inherently recognize it as a link — it's focusable via the Tab key, activatable with Enter, and announced as "link" by screen readers. This built-in behavior is part of the element's implicit ARIA role, which is link.
When you explicitly add role="link" to an <a href="..."> element, you're telling assistive technologies something they already know. The W3C validator flags this as unnecessary because it violates the principle of not redundantly setting ARIA roles that match an element's native semantics. This principle is codified in the first rule of ARIA use: "If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so."
While a redundant role="link" won't typically break anything, it creates noise in your markup. It can also signal to other developers that the role is necessary, leading to confusion or cargo-cult patterns. Clean, semantic HTML that relies on native roles is easier to maintain and less error-prone.
The role="link" attribute is legitimately useful when a non-interactive element like a <span> or <div> needs to behave as a link. In that case, you must also manually implement keyboard interaction (focus via tabindex, activation via Enter key handling) and provide an accessible name. But when you already have a proper <a> element with href, all of that comes for free — no ARIA needed.
Examples
❌ Incorrect: redundant role="link" on an anchor
<a href="/about" role="link">About Us</a>
The role="link" is redundant here because the <a> element with href already has an implicit role of link.
✅ Correct: anchor without redundant role
<a href="/about">About Us</a>
Simply remove the role="link" attribute. The browser and assistive technologies already treat this as a link.
✅ Correct: using role="link" on a non-semantic element (when necessary)
<span role="link" tabindex="0" onclick="location.href='/about'" onkeydown="if(event.key==='Enter') location.href='/about'">
About Us
</span>
This is the legitimate use case for role="link" — when you cannot use a native <a> element and need to make a non-interactive element behave like a link. Note the additional work required: tabindex="0" for keyboard focusability, a click handler, and a keydown handler for Enter key activation. Using a proper <a> element avoids all of this extra effort.
❌ Incorrect: multiple anchors with redundant roles
<nav>
<a href="/" role="link">Home</a>
<a href="/products" role="link">Products</a>
<a href="/contact" role="link">Contact</a>
</nav>
✅ Correct: clean navigation without redundant roles
<nav>
<a href="/">Home</a>
<a href="/products">Products</a>
<a href="/contact">Contact</a>
</nav>
The role="list" attribute is redundant on an <ol> element because it already has an implicit ARIA role of list.
HTML elements come with built-in (implicit) ARIA roles that convey their purpose to assistive technologies. The <ol> and <ul> elements both have an implicit role of list, so explicitly adding role="list" is unnecessary and creates noise in your markup.
That said, there's a well-known reason some developers add this role intentionally. Safari removes list semantics when list-style: none is applied via CSS. Adding role="list" is a common workaround to restore those semantics for VoiceOver users. If this is your situation, the W3C warning is technically correct but you may choose to keep the role for accessibility reasons.
If you don't need the Safari workaround, simply remove the role attribute.
Before
<ol role="list">
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
After
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
The HTML specification assigns implicit ARIA roles to many elements, meaning browsers and assistive technologies already understand their purpose without any extra attributes. The ul element has a built-in role of list, the nav element has a role of navigation, the button element has a role of button, and so on. When you explicitly add a role that matches the element's implicit role, it creates redundancy that the validator warns about.
This principle is formalized as the first rule of ARIA use: do not use ARIA if a native HTML element already provides the semantics you need. Adding redundant ARIA roles clutters your markup, can confuse developers maintaining the code, and in rare edge cases may cause assistive technologies to announce information twice or behave unexpectedly.
This same warning applies to other elements with implicit roles, such as adding role="navigation" to a nav element, role="banner" to a header element, or role="contentinfo" to a footer element.
A note about Safari and list-style: none
There is one well-known exception worth mentioning. Safari intentionally removes list semantics from ul and ol elements when list-style: none is applied via CSS. This means VoiceOver on macOS and iOS will not announce the element as a list. In this specific case, some developers deliberately add role="list" to restore the list semantics. While the W3C validator will still flag it as redundant (since it evaluates HTML in isolation, without considering CSS), this is a legitimate accessibility pattern where the redundant role serves a real purpose. If you're in this situation, you may choose to keep role="list" and accept the validator warning.
Examples
Incorrect: redundant role="list" on ul
<ul role="list">
<li>Apples</li>
<li>Bananas</li>
<li>Cherries</li>
</ul>
Correct: relying on implicit semantics
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Cherries</li>
</ul>
Incorrect: other common redundant roles
<nav role="navigation">
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
<main role="main">
<h1>Welcome</h1>
</main>
<footer role="contentinfo">
<p>© 2024 Example Inc.</p>
</footer>
Correct: native elements without redundant roles
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
<main>
<h1>Welcome</h1>
</main>
<footer>
<p>© 2024 Example Inc.</p>
</footer>
Acceptable exception: restoring semantics removed by CSS
If your stylesheet strips list markers and you need to preserve list semantics for screen readers, the redundant role is a pragmatic choice:
<!-- list-style: none is applied via CSS, which removes semantics in Safari -->
<ul role="list" class="unstyled-list">
<li>Step one</li>
<li>Step two</li>
<li>Step three</li>
</ul>
In this case, you can suppress or ignore the validator warning, understanding that it serves an accessibility need that the validator cannot detect from the HTML alone.
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