aria-label
Gives an accessible name when visible text is missing.
Learn aria-*, role, aria-label, aria-labelledby, aria-describedby as part of the HTML attribute system: what they configure, where they belong and which mistakes to avoid.
Accessibility
Semantic HTML should always be the first choice. A real button is better than a div with role="button". ARIA and related attributes are useful when you need to label, describe or expose dynamic interface state.
Accessibility attributes can help, but they can also lie. If the attribute says one thing and the interface does another, assistive technology receives the wrong information.
aria-*, role, aria-label, aria-labelledby, aria-describedby. Attributes that help assistive technology understand interface intent. What belongs here
aria-labelGives an accessible name when visible text is missing.
aria-labelledbyUses another element as the accessible name.
aria-describedbyConnects extra help or error text.
aria-expandedExposes open/closed state for disclosure controls.
aria-liveAnnounces dynamic updates.
roleAdds or changes semantic role when native HTML cannot do it.
Syntax in context
Use ARIA to clarify, not to decorate. Prefer native elements when they already provide the correct semantics.
<button type="button" aria-expanded="false" aria-controls="menu"> Menu </button> <nav id="menu" hidden aria-label="Main navigation"> <a href="/">Home</a> </nav>
Good versus weak
<button type="button" aria-expanded="false" aria-controls="menu"> Menu </button> <nav id="menu" hidden aria-label="Main navigation"> <a href="/">Home</a> </nav>
<div role="button" onclick="openMenu()">Menu</div> <button aria-expanded="true">Menu</button>
Rules that matter
Use button, nav, main, label and input before reaching for ARIA.
aria-expanded must change when the panel opens or closes.
An icon-only button needs aria-label or visible text.
Wrong ARIA can be worse than no ARIA.
Production thinking
ARIA exists to fill accessibility gaps when native HTML cannot fully describe a custom interface. Use semantic elements first, then add ARIA only when it tells assistive technology something true and necessary.
These attributes directly affect screen reader output and keyboard workflows. Test them like product behavior, not decoration.
Dynamic UI needs state synchronization. If JavaScript opens a menu, it should also update hidden and aria-expanded.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.