# ARIA Specialist reference: ARIA You Must Use Correctly Part of the `aria-specialist` skill. Read this only when the task reaches these sections. ## ARIA You Must Use Correctly ### Modals ```html ``` Requirements: - Open a native `` with `showModal()`. That makes it modal and gives it the dialog role, so do not add `role="dialog"` (ARIA in HTML marks it not recommended) or `aria-modal`. A custom `div` dialog needs `role="dialog"` and `aria-modal="true"` - `aria-labelledby` pointing to the heading (or `aria-label` when there is no visible title) - Focus moves into the dialog when it opens: usually the first focusable element; a static element at the top when the content is long; the least destructive button when the action cannot be undone (APG Dialog (Modal) pattern) - A visible button that closes the dialog is in its Tab sequence - Tab and Shift+Tab stay inside the dialog; Escape closes it and returns focus to the trigger - Heading starts at H2 (H1 is the page title) - `aria-haspopup="dialog"` on the trigger is valid ARIA 1.2 but optional; the APG dialog pattern does not use it ### Tabs ```html
Content
``` Requirements: - Container has `role="tablist"`, labelled with `aria-labelledby` when a visible label exists, otherwise `aria-label` - Each tab is a ` ``` Requirements: - Toggle button inside a heading element - `aria-expanded` reflects open/closed state - `aria-controls` links to panel ID - Panel may have `role="region"` and `aria-labelledby`; the APG says to avoid this when it causes landmark proliferation, for example with more than about six panels that can be open at once - Enter or Space on the header button expands or collapses its panel; Tab moves through the headers and any focusable panel content. Escape is not part of the APG accordion pattern ### Live Regions ```html
25 results
``` Rules: - Use `aria-live="polite"` for non-urgent updates (search results, filter changes, form success) - Use `aria-live="assertive"` only for critical alerts (errors, session expiring) - Never use assertive for routine updates -- it interrupts whatever the screen reader is currently reading - The live region element must exist in the DOM before content changes - Update the text content, do not replace the element - Keep announcements short and meaningful ### Combobox / Autocomplete ```html
``` Requirements: - Input has `role="combobox"`, `aria-expanded`, `aria-controls`, `aria-autocomplete="list"` - Results list has `role="listbox"`, items have `role="option"` - Arrow keys navigate options - `aria-activedescendant` tracks the current option - Live region announces result count ("3 results available") - Escape closes the list ### Carousels ```html
Descriptive text about what is shown
``` Requirements: - Each slide is `role="group"` with `aria-roledescription="slide"` - `aria-label` gives the position ("1 of 3"); it does not repeat the word "slide", because `aria-roledescription` already supplies it - No auto-rotation, or a rotation control (stop and start) that is the first element in the Tab sequence inside the carousel; rotation also stops while keyboard focus is inside the carousel or the pointer hovers over it - Previous and Next buttons - Slide picker controls labelled by slide ("Go to slide 1"); the button for the displayed slide has `aria-disabled="true"`, or, if the pickers are tabs, follow the Tabs pattern and use `aria-selected` - All images have descriptive alt text