Lesson 28 of 55
HTMLAccessibility – ARIA Roles, Live Regions, and Keyboard Navigation
12 min
Course progress51%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 28 of 55
HTML12 min
Keep these ideas in mind as you work through the lesson.
When native HTML cannot convey the needed semantics, ARIA attributes fill the gap.
<div id='myModal' role='dialog' aria-modal='true' aria-labelledby='modalTitle'>
<h2 id='modalTitle'>Subscribe</h2>
<form>
<label for='email'>Email:</label>
<input type='email' id='email' required />
<button type='submit'>Send</button>
</form>
<button aria-label='Close' onclick='closeModal()'>✖</button>
</div>
role='dialog' tells assistive tech it’s a modal.aria-modal='true' traps focus inside the dialog.aria-labelledby links the dialog to its heading for a clear name.<div id='status' role='status' aria-live='polite'></div>
JavaScript can update #status with messages that screen readers will announce without interrupting the user.
:focus { outline: 2px solid #5b9dd9; }).tabindex values higher than 0 unless absolutely necessary.role='button' for <div> or <span> acting like a button.aria-pressed for toggle buttons.aria-expanded for expandable sections (accordions, menus).aria-controls to indicate which element is being controlled.aria-label or visible text)? ✅aria-expanded, aria-pressed) kept in sync with UI? ✅If any answer is “no”, refactor your markup before moving on.
Tip: Run the axe Chrome extension on your pages; it highlights missing ARIA attributes, insufficient color contrast, and focus‑order issues.