HTML Guides for aria-selected
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.
The aria-selected attribute only accepts the values true, false and undefined, written in lowercase.
aria-selected tells assistive technologies which item in a set is the selected one, such as the active tab in a tab list. It is an ARIA state, not an HTML boolean attribute, so the old habit of repeating the attribute name as its value (checked="checked", selected="selected") doesn't work here. Writing aria-selected="aria-selected" is the most common way to trigger this error. The value undefined is allowed and means the same as leaving the attribute out.
The validator rejects every other value too: selected, yes, 1, TRUE, an empty value, or true with spaces around it. A screen reader can't tell from such a value whether the tab is selected, so users may not hear which one is active. Scripts that switch tabs cause this when they write anything other than the strings "true" and "false" into the attribute.
Set aria-selected="true" on the selected item and aria-selected="false" on the others. On a button, the attribute only has a meaning when the button has a role that supports it, usually role="tab" inside an element with role="tablist". On a button without a role, the validator also reports that the button is missing a role attribute. For a button that turns something on and off, use aria-pressed instead.
Invalid example
<div role="tablist" aria-label="Billing period">
<button role="tab" id="tab-monthly" aria-controls="panel-monthly" aria-selected="aria-selected">Monthly</button>
<button role="tab" id="tab-yearly" aria-controls="panel-yearly">Yearly</button>
</div>
<div role="tabpanel" id="panel-monthly" aria-labelledby="tab-monthly">Monthly prices</div>
<div role="tabpanel" id="panel-yearly" aria-labelledby="tab-yearly" hidden>Yearly prices</div>
Valid example
<div role="tablist" aria-label="Billing period">
<button role="tab" id="tab-monthly" aria-controls="panel-monthly" aria-selected="true">Monthly</button>
<button role="tab" id="tab-yearly" aria-controls="panel-yearly" aria-selected="false">Yearly</button>
</div>
<div role="tabpanel" id="panel-monthly" aria-labelledby="tab-monthly">Monthly prices</div>
<div role="tabpanel" id="panel-yearly" aria-labelledby="tab-yearly" hidden>Yearly prices</div>
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>
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