ARIA, accessible names and focus management
How browsers expose pages to assistive technology — semantic HTML, the accessibility tree and accessible names, then ARIA roles and states, keyboard patterns like roving tabindex, modal dialogs, live regions and focus management in apps.
Reading level
Shows sections up to the selected level.
Before you start
No prerequisites.
This topic starts at Junior level.
Semantic HTML and the accessibility tree
Brauzer markup-dan ağacını, DOM-dan isə ikinci bir ağac qurur: accessibility tree (əlçatanlıq ağacı). Screen reader-lər, səslə idarəetmə proqramları və switch cihazları piksellərə baxmır. Onlar bu ağacı əməliyyat sisteminin accessibility API-si vasitəsilə oxuyur. Ağacdakı hər node-un rolu (button, link, heading, checkbox), adı ("Save", "Search"), state və property-ləri (pressed, expanded, checked, disabled), bəzi rollarda isə həm də dəyəri olur.
Native HTML elementləri bunların hamısını sənin yerinə doldurur:
<button type="button">Save</button>
<div class="btn" onclick="save()">Save</div><button> "Save" adlı button rolu ilə təqdim olunur. O, tab ardıcıllığındadır, Enter və Space onu işə salır, disabled atributu isə onu tab ardıcıllığından çıxarır və deaktiv kimi bildirir. <div> adi konteynerdir: rolu yoxdur, fokus almır, klaviaturadan işə düşmür. Siçanla işləyən istifadəçi iki eyni düymə görür. Klaviatura istifadəçisi ikincisinə çata bilmir, screen reader isə onu adi mətn kimi oxuyur.
Düzgün element sənə nə verir
<a href>: link. Fokus alır, Enter ilə açılır və screen reader-in linklər siyahısında görünür.hrefolmadan nə link sayılır, nə də fokus alır.<button>: cari səhifədə hansısa əməliyyat, məsələn "Menyunu aç", "Sil" və ya "Növbəti slayd".<label for>və<input>: adı olan sahə. Label-ə klikləmək sahəni də fokuslayır.<h1>–<h6>,<nav>,<main>,<header>,<footer>: başlıqlar və landmark-lar. Screen reader istifadəçiləri bütün səhifəni dinləmək əvəzinə bunlar arasında keçid edir.<ul>/<ol>: "list, 5 items" kimi oxunur, istifadəçi məzmunun nə qədər olduğunu bilir.<dialog>,<details>/<summary>,<select>: klaviatura dəstəyi hazır olan tam widget-lər.
Faydalı qayda: link harasa aparır (URL dəyişir), button isə nəsə edir. Modal açan "link" və başqa səhifəyə keçirən "button" insanları çaşdırır: onlar bir şey eşidir, başqa şey alır.
Ağaca baxmaq
Chrome və Firefox DevTools-da seçilmiş elementin hesablanmış rolunu, adını və state-lərini göstərən Accessibility paneli var. Chrome isə Elements panelində DOM ağacının yerinə bütöv accessibility tree-ni də göstərə bilir. Screen reader gözləmədiyin nəsə oxuyursa, ilk baxmalı olduğun yer budur.
WCAG 2.2-nin 4.1.2 Name, Role, Value meyarı (A səviyyəsi) hər interfeys komponenti üçün məhz bu məlumatı tələb edir. Native HTML bunu default olaraq ödəyir; custom widget isə bunu özü təmin etməlidir, ARIA da elə burada lazım olur.
From your markup the browser builds the and, from the DOM, a second tree: the accessibility tree. Screen readers, voice control and switch devices do not look at pixels. They read this tree through the operating system's accessibility API. Each node in it has a role (button, link, heading, checkbox), a name ("Save", "Search"), states and properties (pressed, expanded, checked, disabled) and, for some roles, a value.
Native HTML elements fill all of this in for you:
<button type="button">Save</button>
<div class="btn" onclick="save()">Save</div>The <button> is exposed with role button and the name "Save". It is in the tab order, Enter and Space activate it, and the disabled attribute takes it out of the tab order and exposes it as disabled. The <div> is a generic container: no role, not focusable, no keyboard activation. A mouse user sees two identical buttons. A keyboard user cannot reach the second one, and a screen reader reads it as plain text.
What the right element gives you
<a href>: a link. It is focusable, Enter follows it, and it shows up in the screen reader's list of links. Withouthrefit is neither a link nor focusable.<button>: an action on the current page, such as "Open menu", "Delete" or "Next slide".<label for>with<input>: a named field. Clicking the label also focuses the field.<h1>–<h6>,<nav>,<main>,<header>,<footer>: headings and landmarks. Screen reader users jump between them instead of listening to the whole page.<ul>/<ol>: announced as "list, 5 items", so users know how much content there is.<dialog>,<details>/<summary>,<select>: complete widgets with keyboard support built in.
A useful rule: a link goes somewhere (the URL changes), a button does something. A "link" that opens a modal and a "button" that navigates both mislead people: they hear one thing and get another.
Looking at the tree
Chrome and Firefox DevTools have an Accessibility panel that shows the computed role, name and states of the selected element, and Chrome can show the full accessibility tree in place of the DOM tree in the Elements panel. When a screen reader says something unexpected, this is the first place to look.
WCAG 2.2 success criterion 4.1.2 Name, Role, Value (level A) requires exactly this information for every user interface component. Native HTML meets it by default; a custom widget has to provide it itself, which is where ARIA comes in.
How a control gets its accessible name
Accessible name (əlçatan ad) fokus kontrola gələndə screen reader-in dediyi sözdür ("Search, edit text"). Səslə idarə edən istifadəçi kontrolu işə salmaq üçün də bu adı deyir ("click Search"), screen reader-in link və form sahələri siyahılarında da məhz bu ad görünür. Adın haradan götürüldüyünü Accessible Name and Description Computation (accname) spesifikasiyası müəyyən edir. Sadələşdirsək, boş olmayan mətn verən ilk mənbə qalib gəlir:
aria-labelledby: istinad edilən elementlərin mətni, id-lərin sırası ilə. İstinad edilən element gizli olsa belə işləyir.aria-label: elementin özündə yazılmış sətir.- Native label: form sahələri üçün
<label>,<img>üçünalt, cədvəl üçün<caption>, fieldset üçün<legend>. - Məzmun: adını məzmundan alan rollarda (button, link, heading, tab və s.) daxili elementlərin mətni, içindəki şəkillərin
alt-ı da daxil olmaqla. title, ən son variant kimi. Mətn sahələri üçün HTML-AAMtitle-dan sonraplaceholder-i də əlavə edir.
<button type="button" aria-label="Close dialog">
<svg aria-hidden="true" viewBox="0 0 16 16">…</svg>
</button>
<h2 id="billing-title">Billing address</h2>
<section aria-labelledby="billing-title">…</section>
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email" aria-describedby="email-hint">
<p id="email-hint">We send the receipt here.</p>
<a href="/cart"><img src="/icons/cart.svg" alt="Cart"></a>aria-describedby təsvir (description) əlavə edir: o, addan və roldan sonra oxunur. Köməkçi mətnlər və xəta mesajları üçün düzgün yer budur, ad isə qısa qalır.
Tez-tez rast gəlinən səhvlər
- Adı olmayan, yalnız ikondan ibarət düymələr.
<button><svg>…</svg></button>sadəcə "button" kimi oxunur. Düyməyəaria-label(və ya vizual gizlədilmiş mətn) ver, dekorativ ikonu isəaria-hidden="true"ilə işarələ. - Label əvəzinə placeholder. İstifadəçi yazmağa başlayan kimi yox olur, adətən kontrastı zəifdir və ad hesablanmasında yalnız ən son ehtiyat variantdır. Görünən
<label>saxla, placeholder-dən ən çoxu nümunə format üçün istifadə et. - Görünən mətnlə ziddiyyət təşkil edən ad. WCAG 2.5.3 Label in Name (A səviyyəsi): kontrolun görünən mətn label-i varsa, accessible name bu mətni ehtiva etməlidir, ən yaxşısı lap əvvəldə. Üstündə "Buy" yazılan, adı isə "Add product to basket" olan düymə səslə idarəetmədə işləmir: istifadəçi "click Buy" deyir və heç nə baş vermir.
- Adi
<div>və ya<span>üzərindəaria-label. WAI-ARIA 1.2genericrolunu (vəparagraphkimi başqalarını) adlandırmağı qadağan edir, ona görə screen reader bu adı nəzərə almaya bilər. Ad interaktiv elementlərə, landmark-lara, şəkillərə və oxşar rollara aiddir. - "Read more" adlı on link. Linklər siyahısında onları bir-birindən ayırmaq olmur. Elementin adını link mətninə daxil et: görünən şəkildə və ya vizual gizlədilmiş mətn kimi.
Bu platformadakı Signup form və Product grid challenge-ları əsasən adlar haqqındadır: problemlərin bir hissəsini axe tapır, qalanları isə yalnız səhifəni Tab ilə gəzib hər kontrolun əslində necə adlandığını yoxlayanda üzə çıxır.
The accessible name is what a screen reader says when focus lands on a control ("Search, edit text"), what a voice control user says to activate it ("click Search"), and what appears in the screen reader's lists of links and form fields. The Accessible Name and Description Computation spec (accname) defines where the name comes from. Simplified, the first source that produces non-empty text wins:
aria-labelledby: the text of the referenced elements, in the order of the ids. It works even when the referenced element is hidden.aria-label: a string on the element itself.- The native label:
<label>for form fields,altfor<img>,<caption>for a table,<legend>for a fieldset. - Content: for roles that take their name from content (buttons, links, headings, tabs and others), the text of the descendants, including the
altof images inside. title, as a last resort. For text inputs, HTML-AAM addsplaceholderaftertitle.
<button type="button" aria-label="Close dialog">
<svg aria-hidden="true" viewBox="0 0 16 16">…</svg>
</button>
<h2 id="billing-title">Billing address</h2>
<section aria-labelledby="billing-title">…</section>
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email" aria-describedby="email-hint">
<p id="email-hint">We send the receipt here.</p>
<a href="/cart"><img src="/icons/cart.svg" alt="Cart"></a>aria-describedby adds a description, which is read after the name and role. It is the right place for hints and error messages; the name stays short.
Common mistakes
- Icon-only buttons without a name.
<button><svg>…</svg></button>is announced as just "button". Give the buttonaria-label(or visually hidden text) and mark the decorative iconaria-hidden="true". - Placeholder as the label. It disappears as soon as the user types, usually has low contrast, and is only the last fallback in the name computation. Keep a visible
<label>; use the placeholder for an example format at most. - A name that contradicts the visible text. WCAG 2.5.3 Label in Name (level A): if a control shows a text label, its accessible name must contain that text, ideally at the start. A "Buy" button named "Add product to basket" fails for voice control: the user says "click Buy" and nothing happens.
aria-labelon a plain<div>or<span>. WAI-ARIA 1.2 prohibits naming thegenericrole (and others such asparagraph), so screen readers may ignore it. Names belong on interactive elements, landmarks, images and similar roles.- Ten links called "Read more". In the list of links they are indistinguishable. Put the item name into the link text, visibly or as visually hidden text.
The Signup form and Product grid challenges on this platform are largely about names: axe reports some of the problems, and the rest only show up when you tab through the page and check what each control is actually called.
Keyboard access, tab order and visible focus
Çox insan heç vaxt siçandan istifadə etmir: yalnız klaviatura ilə işləyənlər, screen reader istifadəçiləri, həmçinin switch cihazı və ya səslə idarəetmə ilə işləyənlər — bunlar da arxa planda klaviatura interfeysindən istifadə edir. WCAG 2.1.1 Keyboard (A səviyyəsi) bütün funksionallığın klaviaturadan işləməsini, 2.1.2 No Keyboard Trap (A səviyyəsi) isə fokusun istənilən komponentdən çıxa bilməsini tələb edir.
Gözlənilən düymələr:
- Tab / Shift+Tab interaktiv elementlər arasında keçir.
- Enter linki açır və düyməni işə salır; Space düyməni işə salır və checkbox-u dəyişir.
- Ox düymələri composite widget-lərin içində hərəkət edir: radio qrupları, tab-lar, menyular, listbox-lar.
- Escape dialoqları, menyuları və popup-ları bağlayır.
Tab ardıcıllığı və tabindex
Ardıcıl fokus sırası fokuslana bilən elementlərin DOM-dakı sırasıdır. tabindex elementin fokuslanmasını dəyişir:
<div role="button" tabindex="0">In the tab order, at its DOM position</div>
<h1 tabindex="-1">Focusable from script only</h1>
<input tabindex="3">tabindex="0"elementi DOM-dakı yerində tab ardıcıllığına əlavə edir. Bunu rolu və klaviatura idarəsi olan custom widget üçün işlət. Adi mətni fokuslanan etmək yalnız lazımsız dayanacaqlar yaradır.tabindex="-1"elementielement.focus()ilə fokuslanan edir, amma Tab onu keçib gedir. Fokus hədəfləri (yeni görünüşün başlığı, xətaların xülasəsi) və roving tabindex-in aktiv olmayan elementləri üçün işlədilir.- Müsbət dəyərlər (
1və yuxarı) hər şeydən əvvəl, rəqəm sırası ilə gəzilir. APG bunlardan qəti şəkildə çəkinməyi tövsiyə edir: bir müsbət dəyər bütün səhifənin sırasını dəyişir və markup dəyişən kimi pozulur. WCAG 2.4.3 Focus Order (A səviyyəsi) mənanı qoruyan sıra tələb edir, ona görə sıranı DOM-u düzəltməklə düzəlt.
Blokları yerini dəyişən CSS (order, flex-direction: row-reverse, grid-də yerləşdirmə) yalnız vizual sıranı dəyişir, fokus isə yenə DOM-u izləyir. Bu ikisi fərqlənəndə klaviatura istifadəçisi fokusun ora-bura atıldığını görür.
Native disabled kontrol tab ardıcıllığından çıxır. aria-disabled="true" isə onu fokuslanan saxlayır: istifadəçi kontrolu tapa və niyə əlçatan olmadığını oxuya bilir, amma onda işə düşməsinin qarşısını özün almalısan.
Görünən fokus
WCAG 2.4.7 Focus Visible (AA səviyyəsi): klaviatura istifadəçisi fokusun harada olduğunu görməlidir. Klassik bug reset stylesheet-dəki *:focus { outline: none; } sətridir. Bunun əvəzinə :focus-visible-ı stilləşdir (Baseline, mart 2022-dən geniş əlçatandır). Brauzer onu klaviatura fokusu (və çox vaxt skriptlə köçürülmüş fokus) üçün tətbiq edir, düyməyə siçanla klikləyəndən sonra isə adətən yox:
:focus-visible {
outline: 3px solid var(--focus-ring);
outline-offset: 2px;
}WCAG 2.2 həmçinin 2.4.11 Focus Not Obscured (Minimum) (AA səviyyəsi) meyarını əlavə etdi: fokuslanmış element sənin öz məzmunun, məsələn sticky header və ya cookie banner tərəfindən tamamilə örtülməməlidir. Header-in hündürlüyünə bərabər scroll-padding-top görünüşə gətirilən elementləri header-in altında saxlayır.
Many people never use a mouse: keyboard-only users, screen reader users, and people with switch devices or voice control, which drive the keyboard interface indirectly. WCAG 2.1.1 Keyboard (level A) requires that all functionality works from a keyboard, and 2.1.2 No Keyboard Trap (level A) that focus can always be moved away from a component.
The expected keys:
- Tab / Shift+Tab move between interactive elements.
- Enter follows links and activates buttons; Space activates buttons and toggles checkboxes.
- Arrow keys move inside composite widgets: radio groups, tabs, menus, listboxes.
- Escape closes dialogs, menus and popups.
Tab order and tabindex
The sequential focus order is the DOM order of focusable elements. tabindex changes focusability:
<div role="button" tabindex="0">In the tab order, at its DOM position</div>
<h1 tabindex="-1">Focusable from script only</h1>
<input tabindex="3">tabindex="0"puts an element into the tab order at its DOM position. Use it for a custom widget that also has a role and key handling. Making plain text focusable only adds useless stops.tabindex="-1"makes an element focusable withelement.focus()but skipped by Tab. Use it for focus targets (the heading of a new view, an error summary) and for the inactive items of a roving tabindex.- Positive values (
1and up) are visited before everything else, in numeric order. The APG strongly advises against them: one positive value reorders the whole page and breaks as soon as the markup changes. WCAG 2.4.3 Focus Order (level A) asks for an order that preserves meaning, so fix the order by fixing the DOM.
CSS that reorders boxes (order, flex-direction: row-reverse, grid placement) changes only the visual order; focus still follows the DOM. If the two differ, keyboard users see focus jump around.
A native disabled control leaves the tab order. aria-disabled="true" keeps it focusable, so users can still discover it and read why it is unavailable, but then you must block activation yourself.
Visible focus
WCAG 2.4.7 Focus Visible (level AA): keyboard users must see where focus is. The classic bug is *:focus { outline: none; } in a reset stylesheet. Style :focus-visible instead (Baseline widely available since March 2022). The browser matches it for keyboard focus (and in most cases for focus moved by script), but usually not after a mouse click on a button:
:focus-visible {
outline: 3px solid var(--focus-ring);
outline-offset: 2px;
}WCAG 2.2 added 2.4.11 Focus Not Obscured (Minimum) (level AA): the focused element must not be completely hidden by your own content, such as a sticky header or a cookie banner. scroll-padding-top set to the header height keeps elements scrolled into view below it.
ARIA: roles, states, properties and the rules of use
WAI-ARIA yalnız accessibility tree-nin nə bildirdiyini dəyişən atributlar toplusudur. role rolu təyin edir. aria-* atributları isə istifadə zamanı dəyişən state-ləri (aria-expanded, aria-selected, aria-checked, aria-pressed, aria-invalid, aria-current) və əlaqələri təsvir edən, nadir hallarda dəyişən property-ləri (aria-controls, aria-labelledby, aria-describedby, aria-haspopup) təyin edir.
ARIA heç bir davranış əlavə etmir. role="button" <div>-i fokuslanan etmir, Enter-i klikə çevirmir və görünüşünü dəyişmir. APG bunu "rol bir vəddir" (a role is a promise) kimi ifadə edir: istifadəçiyə həmin rolun klaviatura davranışını vəd edirsən, sonra da onu yazmalı olursan.
<div role="button" tabindex="0" aria-pressed="false">Bold</div>
<button type="button" aria-pressed="false">Bold</button>div-ə hələ də Enter və Space üçün keydown handler, deaktiv vəziyyət və fokus stilləri lazımdır. button-da isə bunların hamısı artıq var; toggle düyməyə çevrilməsi üçün ona yalnız aria-pressed lazım idi.
ARIA-dan istifadə qaydaları
W3C-nin Using ARIA sənədi dörd qayda sadalayır:
- Lazım olan semantika və davranışı olan native HTML elementindən istifadə edə bilirsənsə, ondan istifadə et. Bu, "ARIA-nın birinci qaydası"dır.
- Native semantikanı, həqiqətən məcbur deyilsənsə, dəyişmə.
<h2 role="tab">başlıq olmaqdan çıxır.<button>-u başlığın içinə qoy və ya rolu wrapper-ə ver. - Bütün interaktiv ARIA kontrolları klaviatura ilə işləməlidir.
role="slider"əlavə edirsənsə, ox düymələrini də yazmalısan. - Fokuslanan elementdə
role="presentation"və yaaria-hidden="true"işlətmə. Klaviatura istifadəçisi screen reader üçün mövcud olmayan bir şeyin üstünə düşər.
APG də "No ARIA is better than bad ARIA" başlığı altında eyni fikri deyir: səhv ARIA interfeysi ona güvənən insanlara yanlış təqdim edir, bu isə ümumiyyətlə ARIA olmamasından daha pisdir.
State-lər UI-ı izləməlidir
ARIA state-ləri istifadəçi ilə müqavilədir. İnterfeys dəyişəndə atribut da onunla birlikdə dəyişir: menyu açıq olduqca menyu düyməsində aria-expanded, yalnız bir tab-da aria-selected="true", cari səhifənin naviqasiya linkində aria-current="page". Tez-tez rast gəlinən bug: atribut markup-da bir dəfə yazılır və heç vaxt yenilənmir, nəticədə screen reader açıq menyu üçün "collapsed" deyir. React-də atributu UI-ı idarə edən eyni state-dən çıxar:
function FiltersToggle({ open, onToggle }) {
return (
<button
type="button"
aria-expanded={open}
aria-controls="filters"
onClick={onToggle}
>
Filters
</button>
);
}React boolean dəyəri "true" və ya "false" sətri kimi render edir, ARIA da məhz bunu gözləyir.
Atributun həmin rol üçün mövcud olub-olmadığını da yoxla: aria-checked checkbox, radio və switch-lərə, aria-selected isə tab, option və grid xanalarına aiddir. Rolun dəstəkləmədiyi atributları həm axe, həm də Accessibility paneli göstərir.
WAI-ARIA is a set of attributes that changes only what the accessibility tree reports. role sets the role. aria-* attributes set states, which change during use (aria-expanded, aria-selected, aria-checked, aria-pressed, aria-invalid, aria-current), and properties, which describe relationships and rarely change (aria-controls, aria-labelledby, aria-describedby, aria-haspopup).
ARIA adds no behaviour. role="button" does not make a <div> focusable, does not turn Enter into a click and does not change how it looks. The APG puts it as "a role is a promise": you promise the user the keyboard behaviour of that role and then have to write it.
<div role="button" tabindex="0" aria-pressed="false">Bold</div>
<button type="button" aria-pressed="false">Bold</button>The div still needs a keydown handler for Enter and Space, a disabled state and focus styles. The button already has all of it; it only needed aria-pressed to become a toggle button.
The rules of ARIA use
The W3C note Using ARIA lists four rules:
- If you can use a native HTML element with the semantics and behaviour you need, do so. This is the "first rule of ARIA".
- Do not change native semantics unless you really have to.
<h2 role="tab">stops being a heading. Put a<button>inside the heading, or the role on a wrapper. - All interactive ARIA controls must be usable with the keyboard. Adding
role="slider"means implementing the arrow keys too. - Do not use
role="presentation"oraria-hidden="true"on a focusable element. Keyboard users would land on something that does not exist for their screen reader.
The APG makes the same point under the heading "No ARIA is better than bad ARIA": incorrect ARIA misrepresents the interface to the people who rely on it, which is worse than no ARIA at all.
States must follow the UI
ARIA states are a contract with the user. When the interface changes, the attribute changes with it: aria-expanded on a menu button while the menu is open, aria-selected="true" on exactly one tab, aria-current="page" on the navigation link of the current page. A common bug is an attribute written once in the markup and never updated, so the screen reader says "collapsed" for an open menu. In React, derive the attribute from the same state that drives the UI:
function FiltersToggle({ open, onToggle }) {
return (
<button
type="button"
aria-expanded={open}
aria-controls="filters"
onClick={onToggle}
>
Filters
</button>
);
}React renders the boolean as the string "true" or "false", which is exactly what ARIA expects.
Also check that the attribute exists for the role: aria-checked belongs to checkboxes, radios and switches, and aria-selected to tabs, options and grid cells. axe and the Accessibility panel both report attributes that a role does not support.
Composite widgets: tabs and the roving tabindex
Çoxlu elementdən ibarət widget-lər (tab-lar, radio qrupları, menyular, listbox-lar, toolbar-lar, grid-lər) composite widget adlanır. Tab widget-in içinə bir dəfə girir və ondan bir dəfə çıxır, içindəki elementlər arasında isə ox düymələri ilə hərəkət edilir. Səkkiz tab-ı olan tablist səkkiz yox, bir Tab dayanacağı tutur.
APG-nin Tabs şablonu:
- Konteynerin
role="tablist"rolu və adı var; hər tab-darole="tab",aria-selectedvəaria-controlsolur; hər panelinrole="tabpanel"rolu və öz tab-ına istinad edənaria-labelledby-ı olur. - Tab fokusu aktiv tab-a gətirir, növbəti Tab isə panelə keçir. İçində fokuslanan elementi olmayan panel
tabindex="0"alır ki, onun mətninə çatmaq mümkün olsun. - Sol / sağ ox əvvəlki / növbəti tab-a keçir və sonlarda dövrə vurur; Home və End (istəyə bağlı) birinci və sonuncu tab-a atlayır.
- Avtomatik aktivləşmə (fokus hərəkət etdikcə panel dəyişir) panellər gözə çarpan gecikmə olmadan göstərilirsə tövsiyə olunur. Panel əvvəlcə yüklənməlidirsə, əl ilə aktivləşmə seç: oxlar fokusu daşıyır, Enter və ya Space seçir.
Roving tabindex
Yalnız bir tab-da tabindex="0" olur: seçilmiş tab-da. Qalanlarının hamısında tabindex="-1" olur. Ox düymələri 0-ı yeni tab-a keçirir və onun üzərində focus() çağırır:
function Tabs({ tabs }) {
const [active, setActive] = useState(0);
const refs = useRef([]);
function onKeyDown(event) {
const last = tabs.length - 1;
const next = {
ArrowRight: active === last ? 0 : active + 1,
ArrowLeft: active === 0 ? last : active - 1,
Home: 0,
End: last,
}[event.key];
if (next === undefined) return;
event.preventDefault();
setActive(next);
refs.current[next].focus();
}
return (
<>
<div role="tablist" aria-label="Account settings" onKeyDown={onKeyDown}>
{tabs.map((tab, i) => (
<button
key={tab.id}
ref={(el) => {
refs.current[i] = el;
}}
type="button"
role="tab"
id={`tab-${tab.id}`}
aria-selected={i === active}
aria-controls={`panel-${tab.id}`}
tabIndex={i === active ? 0 : -1}
onClick={() => setActive(i)}
>
{tab.label}
</button>
))}
</div>
{tabs.map((tab, i) => (
<div
key={tab.id}
role="tabpanel"
id={`panel-${tab.id}`}
aria-labelledby={`tab-${tab.id}`}
tabIndex={0}
hidden={i !== active}
>
{tab.content}
</div>
))}
</>
);
}Bu, avtomatik aktivləşmədir: fokusun yerini dəyişmək həm də seçim edir. tabIndex={0} yalnız seçilmiş tab-da olduğu üçün kənardan gələn Tab həmişə məhz onun üzərinə düşür.
aria-activedescendant
Alternativ yol DOM fokusunu konteynerdə saxlayır və aria-activedescendant-a "aktiv" elementin id-sini yazır; köməkçi texnologiya həmin elementi fokuslanmış sayır. Vurğulamanı özün çəkirsən və elementi özün görünüşə gətirirsən. Combobox üçün adi seçim budur: oxlar variantlar arasında gəzərkən fokus mətn sahəsində qalmalıdır. Elementlərin özləri fokus ala bilirsə, roving tabindex daha sadədir.
Aktiv olmayan panelləri gizlətmək
Aktiv olmayan panellər sadəcə görünməz olmamalı, hamı üçün aradan qalxmalıdır: hidden, ümumiyyətlə render etməmək və ya vizual gizlətmənin üstündən inert (animasiyalı keçid üçün). Yalnız opacity: 0 və ya aria-hidden ilə gizlədilmiş panellərin link və düymələri tab ardıcıllığında qalır.
Tabs challenge-ı sənə düzəltmək üçün yarımçıq tab widget-i verir.
Widgets made of many items (tabs, radio groups, menus, listboxes, toolbars, grids) are composite widgets. Tab moves into the widget once and out of it once; the arrow keys move between the items inside. A tablist with eight tabs costs one Tab stop, not eight.
The APG Tabs pattern:
- The container has
role="tablist"and a name; each tab hasrole="tab",aria-selectedandaria-controls; each panel hasrole="tabpanel"andaria-labelledbypointing at its tab. - Tab moves focus to the active tab; the next Tab goes to the panel. A panel without focusable content gets
tabindex="0"so its text can be reached. - Left / Right Arrow move to the previous / next tab and wrap around at the ends; Home and End (optional) jump to the first and last tab.
- Automatic activation (the panel changes as focus moves) is recommended when panels appear without noticeable delay. If a panel has to load first, use manual activation: arrows move focus, Enter or Space selects.
Roving tabindex
Exactly one tab has tabindex="0": the selected one. All others have tabindex="-1". The arrow keys move the 0 and call focus() on the new tab:
function Tabs({ tabs }) {
const [active, setActive] = useState(0);
const refs = useRef([]);
function onKeyDown(event) {
const last = tabs.length - 1;
const next = {
ArrowRight: active === last ? 0 : active + 1,
ArrowLeft: active === 0 ? last : active - 1,
Home: 0,
End: last,
}[event.key];
if (next === undefined) return;
event.preventDefault();
setActive(next);
refs.current[next].focus();
}
return (
<>
<div role="tablist" aria-label="Account settings" onKeyDown={onKeyDown}>
{tabs.map((tab, i) => (
<button
key={tab.id}
ref={(el) => {
refs.current[i] = el;
}}
type="button"
role="tab"
id={`tab-${tab.id}`}
aria-selected={i === active}
aria-controls={`panel-${tab.id}`}
tabIndex={i === active ? 0 : -1}
onClick={() => setActive(i)}
>
{tab.label}
</button>
))}
</div>
{tabs.map((tab, i) => (
<div
key={tab.id}
role="tabpanel"
id={`panel-${tab.id}`}
aria-labelledby={`tab-${tab.id}`}
tabIndex={0}
hidden={i !== active}
>
{tab.content}
</div>
))}
</>
);
}This is automatic activation: moving focus also selects. Because the selected tab is the only one with tabIndex={0}, Tab from outside always lands on it.
aria-activedescendant
The alternative keeps DOM focus on the container and sets aria-activedescendant to the id of the "active" item; assistive technology treats that item as focused. You draw the highlight yourself and scroll the item into view. It is the usual choice for a combobox, where focus must stay in the text input while the arrows move through the options. When the items can take focus themselves, roving tabindex is simpler.
Hiding the inactive panels
Inactive panels must be gone for everyone, not just invisible: hidden, not rendering them at all, or inert on top of a visual hiding (for an animated transition). Panels hidden only with opacity: 0 or aria-hidden keep their links and buttons in the tab order.
The Tabs challenge gives you a half-finished tabs widget to repair.
Modal dialogs: move focus in, keep it there, give it back
Modal dialoq bağlanana qədər səhifənin qalan hissəsini əlçatmaz edir. APG-nin Dialog (Modal) şablonu beş şey tələb edir:
- Açılanda fokusu içəri gətir. Adətən birinci fokuslanan elementə; geri qaytarılması çətin olan addımda, məsələn məlumat silinəndə, ən az zərərli əməliyyata (Cancel); uzun məzmunda isə yuxarıdakı,
tabindex="-1"verilmiş statik elementə. - Fokusu içəridə saxla. Tab və Shift+Tab dialoqun kontrolları arasında dövrə vurur; arxadakı səhifəyə nə çatmaq, nə də onu oxumaq olur.
- Escape dialoqu bağlayır.
- Fokusu dialoqu açan elementə qaytar. O element artıq yoxdursa, fokusu iş axınını davam etdirən yerə apar.
- Dialoqu təqdim et:
role="dialog",aria-modal="true"və ad, adətən görünən başlığa istinad edənaria-labelledby.
showModal() ilə açılan native <dialog> (Baseline, mart 2022-dən geniş əlçatandır) bunun böyük hissəsini sənin yerinə edir:
<button type="button" id="delete-project">Delete project</button>
<dialog id="confirm" aria-labelledby="confirm-title">
<h2 id="confirm-title">Delete "Website redesign"?</h2>
<p>This removes the project and its 24 tasks.</p>
<form method="dialog">
<button value="cancel" autofocus>Cancel</button>
<button value="delete">Delete</button>
</form>
</dialog>const dialog = document.getElementById("confirm");
document.getElementById("delete-project").addEventListener("click", () => {
dialog.showModal();
});
dialog.addEventListener("close", () => {
if (dialog.returnValue === "delete") deleteProject();
});showModal() dialoqu hər şeyin üstündəki top layer-ə qoyur, səhifənin qalanını inert edir (fokus almır, kliklənmir, köməkçi texnologiyadan gizlənir), autofocus olan elementi və ya birinci fokuslanan elementi fokuslayır və dialoqu modal kimi təqdim edir. Escape cancel hadisəsini işə salır və dialoqu bağlayır. Dialoq bağlananda brauzer fokusu açılmazdan əvvəl fokusda olan elementə qaytarır. <form method="dialog"> içindəki düymə dialoqu bağlayır və returnValue-ya öz dəyərini yazır. <dialog>-un özünə tabindex vermə. Geri qaytarılmayan təsdiq üçün APG Alert Dialog şablonunu tövsiyə edir, role="alertdialog" isə <dialog> üzərində icazəlidir.
APG-dən bir fərq: native modalda sonuncu kontroldan sonra basılan Tab birinci kontrola qayıtmaq əvəzinə brauzerin öz interfeysinə keçə bilər. Arxadakı səhifə yenə də əlçatmaz qalır.
Div-lərdən qurulmuş dialoq
<dialog> olmadan hər hissəni özün qurursan: role="dialog", aria-modal="true" və aria-labelledby; əl ilə yazılmış Tab tələsi əvəzinə səhifənin qalanına inert (Baseline, aprel 2023-dən geniş əlçatandır); Escape üçün keydown handler; açmazdan əvvəl yadda saxlanan və bağlandıqdan sonra yenidən fokuslanan document.activeElement. Sıra vacibdir: trigger üzərində focus() çağırmazdan əvvəl səhifədən inert-i götür, çünki inert element fokus ala bilmir.
Modal dialog challenge-ı sənə düzəltmək üçün div-lərdən qurulmuş təsdiq dialoqu verir.
A modal dialog makes the rest of the page unavailable until it closes. The APG Dialog (Modal) pattern asks for five things:
- Move focus in when it opens. Usually the first focusable element; for a step that is hard to undo, such as deleting data, the least destructive action (Cancel); for long content, a static element at the top with
tabindex="-1". - Keep focus inside. Tab and Shift+Tab cycle through the dialog's controls; the page behind cannot be reached or read.
- Escape closes it.
- Return focus to the element that opened it. If that element no longer exists, move focus somewhere that continues the workflow.
- Expose it:
role="dialog",aria-modal="true"and a name, usuallyaria-labelledbypointing at the visible title.
Native <dialog> with showModal() (Baseline widely available since March 2022) does most of this for you:
<button type="button" id="delete-project">Delete project</button>
<dialog id="confirm" aria-labelledby="confirm-title">
<h2 id="confirm-title">Delete "Website redesign"?</h2>
<p>This removes the project and its 24 tasks.</p>
<form method="dialog">
<button value="cancel" autofocus>Cancel</button>
<button value="delete">Delete</button>
</form>
</dialog>const dialog = document.getElementById("confirm");
document.getElementById("delete-project").addEventListener("click", () => {
dialog.showModal();
});
dialog.addEventListener("close", () => {
if (dialog.returnValue === "delete") deleteProject();
});showModal() puts the dialog in the top layer above everything, makes the rest of the page inert (not focusable, not clickable, hidden from assistive technology), focuses the autofocus element or the first focusable one, and exposes the dialog as modal. Escape fires cancel and closes it. When it closes, the browser returns focus to the element that was focused before it opened. A button inside <form method="dialog"> closes the dialog and sets returnValue to its value. Do not put tabindex on the <dialog> itself. For a destructive confirmation the APG points to the Alert Dialog pattern, and role="alertdialog" is allowed on <dialog>.
One difference from the APG: with a native modal, Tab after the last control may move into the browser's own UI instead of wrapping to the first control. The page behind still stays unreachable.
Built from divs
Without <dialog> you build each piece yourself: role="dialog", aria-modal="true" and aria-labelledby; inert on the rest of the page (Baseline widely available since April 2023) instead of a hand-written Tab trap; a keydown handler for Escape; and document.activeElement saved before opening and focused again after closing. Order matters: remove inert from the page before you call focus() on the trigger, because an inert element cannot take focus.
The Modal dialog challenge gives you a confirmation built from divs to repair.
Hiding content and announcing changes
"Gizli" sözü üç fərqli şey deməkdir və bunları qarışdırmaq çoxlu bug-a səbəb olur:
| Üsul | Görünür | Accessibility tree-dədir | Fokus alır |
|---|---|---|---|
hidden, display: none, visibility: hidden | yox | yox | yox |
aria-hidden="true" | bəli | yox | bəli |
| vizual gizlədən CSS | yox | bəli | bəli |
opacity: 0, sıfır hündürlük, ekrandan kənara çıxarmaq | yox | bəli | bəli |
inert | bəli | yox | yox |
hidden/display: noneməzmunu hamı üçün aradan qaldırır: bağlı menyular, aktiv olmayan tab panelləri. Tələ:hiddenbrauzerin özdisplay: noneqaydası ilə işləyir və.panel { display: grid; }kimi istənilən müəllif qaydası onu üstələyir, nəticədə "gizli" panel yenidən görünür. Baza stillərinə[hidden] { display: none !important; }əlavə et.aria-hidden="true"məzmunu yalnız köməkçi texnologiyadan gizlədir: mətnin yanındakı dekorativ ikonlar, artıq elan olunmuş bir şeyin vizual təkrarı. Heç vaxt fokuslanan elementdə və ya onu ehtiva edən konteynerdə işlətmə (ARIA-nın dördüncü qaydası).- Vizual gizlədilmiş mətn yalnız screen reader üçündür, məsələn "Read more about the Trail backpack" və ya fokus alanda görünən skip link:
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}Live region-lar
Məzmun dəyişəndə fokus yerindən tərpənmirsə ("Saved" toast-ı, axtarış nəticələrinin sayı, asinxron yoxlamadan sonra çıxan xəta), screen reader heç nə demir. O, dəyişikliyi yalnız live region içində baş verəndə elan edir:
<div id="cart-status" role="status" class="visually-hidden"></div>async function addToCart(product) {
await api.addToCart(product.id);
document.getElementById("cart-status").textContent = `${product.name} added to cart`;
}role="status"-un implicit dəyərləriaria-live="polite"vəaria-atomic="true"-dur: mesaj istifadəçi boş olanda oxunur. Mesajların çoxu üçün bunu işlət. WCAG 4.1.3 Status Messages (AA səviyyəsi) status mesajlarının rol və ya property vasitəsilə təqdim olunmasını tələb edir ki, köməkçi texnologiya onları fokusu köçürmədən çatdıra bilsin.role="alert"assertive-dir (aria-live="assertive",aria-atomic="true") və o an oxunan hər şeyi kəsir. Onu təcili, vaxta həssas xətalar üçün saxla.- Region dəyişiklikdən əvvəl mövcud olmalıdır. Screen reader artıq tanıdığı region-dakı dəyişiklikləri elan edir. Onu bir dəfə, boş halda render et (məsələn, layout-da), sonra mətnini dəyiş.
<div role="status">Saved</div>-i bir addımda əlavə etmək çox vaxt eşidilmir; MDN qeyd edir ki,role="alert"istisnadır və sonradan əlavə olunanda da elan edilir. - Az elan et. Hər hadisəyə bir qısa mesaj, hər düymə basışına elan yox (canlı nəticə sayına tətbiq et), daim dəyişən məzmunun, məsələn işləyən saatın ətrafında live region yox.
"Hidden" means three different things, and mixing them up causes many bugs:
| Technique | Visible | In the accessibility tree | Focusable |
|---|---|---|---|
hidden, display: none, visibility: hidden | no | no | no |
aria-hidden="true" | yes | no | yes |
| visually hidden CSS | no | yes | yes |
opacity: 0, zero height, moved off-screen | no | yes | yes |
inert | yes | no | no |
hidden/display: noneremove content for everyone: closed menus, inactive tab panels. A trap:hiddenworks through the browser's owndisplay: none, and any author rule such as.panel { display: grid; }overrides it, so the "hidden" panel shows up again. Add[hidden] { display: none !important; }to your base styles.aria-hidden="true"hides content from assistive technology only: decorative icons next to text, a visual duplicate of something already announced. Never on a focusable element or on a container of one (the fourth rule of ARIA).- Visually hidden text is for screen readers only, such as "Read more about the Trail backpack" or a skip link that appears on focus:
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}Live regions
When content changes and focus does not move (a "Saved" toast, the number of search results, an error after async validation), a screen reader says nothing. It announces the change only if it happens inside a live region:
<div id="cart-status" role="status" class="visually-hidden"></div>async function addToCart(product) {
await api.addToCart(product.id);
document.getElementById("cart-status").textContent = `${product.name} added to cart`;
}role="status"has an implicitaria-live="polite"andaria-atomic="true": the message is read when the user is idle. Use it for most messages. WCAG 4.1.3 Status Messages (level AA) requires status messages to be exposed through a role or property, so assistive technology can present them without moving focus.role="alert"is assertive (aria-live="assertive",aria-atomic="true") and interrupts whatever is being read. Keep it for urgent, time-sensitive errors.- The region must exist before the change. Screen readers announce changes to a region they already know about. Render it once, empty (in the layout, for example), and then change its text. Inserting
<div role="status">Saved</div>in one step is often missed; MDN notes thatrole="alert"is the exception and is announced even when injected. - Announce less. One short message per event, no announcement per keystroke ( a live result count), and no live region around content that changes all the time, such as a ticking clock.
Focus in dynamic apps, and what automated checks miss
Single-page tətbiqdə DOM istifadəçinin gözü qarşısında dəyişir. Fokuslanmış element silinəndə document.activeElement <body> olur: növbəti Tab səhifənin lap əvvəlindən başlayır, screen reader isə ümumiyyətlə heç nə deməyə bilər. UI-ın fokuslanmış elementi sildiyi və ya əvəzlədiyi hər yerdə qərar lazımdır.
- Fokusdakı elementin silinməsi. Fokusu növbəti elementə, element sonuncu idisə əvvəlkinə, siyahı boşalıbsa siyahının başlığına köçür.
- Route dəyişikliyi. Yeni görünüş səhifə yüklənmədən çıxır, ona görə heç nə elan olunmur. Onun
<h1>-ini (tabindex="-1"ilə) fokusla,document.title-ı yenilə və ya səhifəni live region-da elan et. Next.js-də hazır route announcer var: o, əvvəlcədocument.title-ı, sonra<h1>-i, sonra pathname-i oxuyur. Klient tərəfində routing mövzusu bunu ətraflı izah edir. - Popover, menyu və inline redaktorların bağlanması. Fokusu trigger-ə qaytar: "Save"-dən sonra yenidən görünən "Edit" düyməsini fokusla.
- "Load more" və sonsuz siyahılar. Fokusu birinci yeni elementə köçür və ya düymədə saxla və neçə element əlavə olunduğunu elan et.
- Form xətaları. Uğursuz göndərişdən sonra birinci səhv sahəni və ya sahələrə link verən xəta xülasəsini fokusla; hər mesajı
aria-describedbyilə öz sahəsinə bağla vəaria-invalid="true"təyin et.
function removeTodo(button) {
const buttons = [...list.querySelectorAll("button.remove")];
const i = buttons.indexOf(button);
const next = buttons[i + 1] ?? buttons[i - 1];
button.closest("li").remove();
(next ?? listHeading).focus();
}listHeading-in tabindex="-1" atributu var: o, skriptdən fokus ala bilir, amma Tab dayanacağına çevrilmir. React-də eyni məntiqi state yeniləndikdən sonra işə sal, məsələn fokuslanacaq id-ni yadda saxla və siyahı yenidən render olunandan sonra effektdə focus() çağır.
Avtomatik yoxlamalar nəyi tapır, nəyi tapmır
Lighthouse-un accessibility auditi də daxil olmaqla, axe-core DOM üzərində qaydaları yoxlayır: çatışmayan adlar, rolun dəstəkləmədiyi ARIA atributları, kontrast, təkrarlanan id-lər, label-i olmayan sahələr. Onu hazırlayan Deque şirkəti deyir ki, axe-core WCAG problemlərinin orta hesabla 57%-ni avtomatik tapır, bəzi nəticələri isə əl ilə yoxlanmaq üçün "incomplete" kimi qeyd edir. Onun qiymətləndirə bilmədiyi şeylər:
- fokus sırası məntiqlidirmi, dialoq bağlananda fokus geri qayıdırmı;
- widget-də ox düymələri işləyirmi, Escape onu bağlayırmı;
- ad sadəcə mövcuddur, yoxsa həqiqətən mənalıdır ("button 1", "image");
- live mesaj düzgün anda və bir dəfə elan olunurmu.
A11y Hunt challenge-larında axe problemlərinin yalnız klaviatura ilə gəzəndə üzə çıxan problemlərlə qarışıq verilməsinin səbəbi budur. Praktik qayda: reqressiyaları tutmaq üçün lint (eslint-plugin-jsx-a11y) və komponent və end-to-end testlərində axe, sonra hər kritik axın üçün klaviatura ilə yoxlama (hamısını Tab ilə keç, hər widget-i aç və bağla, siçana toxunma), Accessibility panelində adlara baxış və VoiceOver və ya NVDA kimi screen reader ilə sınaq.
In a single-page app the DOM changes under the user. When the focused element is removed, document.activeElement becomes <body>: the next Tab starts again from the top of the page, and a screen reader may say nothing at all. Every place where your UI removes or replaces the focused element needs a decision.
- Deleting the focused item. Move focus to the next item, to the previous one if it was the last, or to the list's heading when the list is now empty.
- Route changes. The new view appears without a page load, so nothing is announced. Focus its
<h1>(withtabindex="-1"), updatedocument.title, or announce the page in a live region. Next.js has a built-in route announcer that readsdocument.title, then the<h1>, then the pathname. The Client-side routing topic covers this in detail. - Closing popovers, menus and inline editors. Return focus to the trigger: after "Save", focus the "Edit" button that is shown again.
- "Load more" and infinite lists. Move focus to the first new item, or keep it on the button and announce how many items were added.
- Form errors. After a failed submit, focus the first invalid field or an error summary that links to the fields; tie each message to its field with
aria-describedbyand setaria-invalid="true".
function removeTodo(button) {
const buttons = [...list.querySelectorAll("button.remove")];
const i = buttons.indexOf(button);
const next = buttons[i + 1] ?? buttons[i - 1];
button.closest("li").remove();
(next ?? listHeading).focus();
}listHeading has tabindex="-1", so it can take focus from script without becoming a Tab stop. In React, run the same logic after the state update, for example by storing the id to focus and calling focus() in an effect once the list has re-rendered.
What automated checks find, and what they miss
axe-core, which also powers Lighthouse's accessibility audit, checks rules over the DOM: missing names, ARIA attributes a role does not support, contrast, duplicate ids, missing labels. Deque, the company behind it, says it finds on average 57% of WCAG issues automatically, and it marks some results as "incomplete" for manual review. It cannot judge whether:
- the focus order makes sense, and focus returns after a dialog closes;
- arrow keys work in a widget, and Escape closes it;
- a name is meaningful, not just present ("button 1", "image");
- a live message is announced at the right moment, once.
That is why the A11y Hunt challenges mix axe issues with manual ones that only a keyboard walk-through reveals. A practical routine: lint (eslint-plugin-jsx-a11y) and axe in component and end-to-end tests to catch regressions, then for every critical flow a keyboard pass (Tab through all of it, open and close every widget, never touch the mouse), a look at names in the Accessibility panel, and a run with a screen reader such as VoiceOver or NVDA.
Interview tips
30 saniyəlik cavab. "Köməkçi texnologiya accessibility tree-ni oxuyur: rol, ad, state. Semantik HTML bu ağacı doldurur və klaviatura dəstəyini pulsuz verir, ona görə mən oradan başlayıram. ARIA yalnız ağacın nə bildirdiyini dəyişir və heç bir davranış əlavə etmir, ona görə onu custom widget-lərdəki boşluqları doldurmaq üçün işlədirəm və state-lərini UI ilə sinxron saxlayıram. Sonra fokusu idarə edirəm: həmişə görünən, məntiqli sırada, məzmun açılanda, bağlananda və ya yox olanda isə şüurlu şəkildə köçürülən."
Gözlənilən suallar
- Bu kliklənən
div-i əlçatan et. Ən yaxşı cavab: onu<button>ilə əvəz et. Həqiqətən mümkün deyilsə, sonra sənin üzərinə düşən hər şeyi sadala: rol,tabindex="0", Enter və Space, deaktiv vəziyyət, fokus stilləri. - Screen reader bu düymənin adını haradan bilir? Adın hesablanması:
aria-labelledby,aria-label, native label və yaalt, məzmun,title. 2.5.3 Label in Name meyarını da qeyd et. - Əlçatan modal qur.
showModal()ilə<dialog>və ya əl ilə: rol,aria-modal, ad, səhifədəinert, Escape, fokusun içəri gəlməsi və geri qayıtması. İlkin fokusu niyə məhz ora verdiyini izah et. - Tab-lar və ya menyu üçün klaviatura dəstəyi. Bir Tab dayanacağı, içəridə oxlar, roving tabindex və ya
aria-activedescendant, avtomatik və əl ilə aktivləşmə. aria-hidden,display: nonevə vizual gizlətmə. Hər biri məzmunu kimdən gizlədir və fokuslanan məzmundaaria-hiddenniyə bug-dır.- "Saved" mesajını necə elan edərsən? Əvvəlcədən mövcud olan live region,
role="status", mətn sonradan dəyişdirilir. - Əlçatanlığı necə test edirsən? Avtomatik yoxlamalar, üstəlik klaviatura ilə gəzinti, Accessibility paneli və screen reader; avtomatika problemlərin yalnız bir hissəsini tapır.
Bal itirdən səhvlər
- "Əlçatan olsun deyə ARIA əlavə et." Davranışı olmayan ARIA pozulmuş vəddir, səhv ARIA isə heç olmamasından pisdir.
- Əvəzində başqa fokus stili vermədən
outline: none. - Sıranı DOM-u düzəltmək əvəzinə müsbət
tabindexilə "düzəltmək". - Hər yerdə
aria-label: adidiv-lərdə və ya görünən mətni başqa sözlərlə əvəz edərək. - Lighthouse-da 100 balı "əlçatandır" kimi qəbul etmək.
Senior səviyyəni göstərən məqamlar
Ayrı-ayrı düzəlişlərdən yox, sistemdən danış: məhsul komandaları yenidən yazmasın deyə design system-də əlçatan primitivlər (dialog, tabs, menu, combobox); CI-da lint və axe, kritik axınlar üçün klaviatura testləri; bütün tətbiq üçün route dəyişikliklərində vahid fokus siyasəti. Hədəfi adlandır, adətən WCAG 2.2 AA səviyyəsi, və tətbiq olunduğu yerlərdə hüquqi konteksti, məsələn 28 iyun 2025-ci ildən qüvvədə olan European Accessibility Act-i.
A 30-second answer. "Assistive technology reads the accessibility tree: role, name, state. Semantic HTML fills it in and brings keyboard support for free, so I start there. ARIA only changes what the tree reports and adds no behaviour, so I use it to fill gaps in custom widgets and keep its states in sync with the UI. Then I manage focus: always visible, in a logical order, and moved deliberately when content opens, closes or disappears."
Questions you are likely to get
- Make this clickable
divaccessible. Best answer: replace it with a<button>. If you really cannot, list everything that is then your job: role,tabindex="0", Enter and Space, the disabled state, focus styles. - How does a screen reader know what this button is called? The name computation:
aria-labelledby,aria-label, the native label oralt, the content,title. Mention 2.5.3 Label in Name. - Build an accessible modal.
<dialog>withshowModal(), or by hand: role,aria-modal, a name,inerton the page, Escape, focus in and back. Explain your choice of initial focus. - Keyboard support for tabs or a menu. One Tab stop, arrows inside, roving tabindex or
aria-activedescendant, automatic vs manual activation. aria-hiddenvsdisplay: nonevs visually hidden. Who each one hides content from, and whyaria-hiddenon focusable content is a bug.- How do you announce "Saved"? A live region that already exists,
role="status", text changed afterwards. - How do you test accessibility? Automated checks plus a keyboard pass, the Accessibility panel and a screen reader; automation finds only part of the issues.
Mistakes that cost points
- "Add ARIA to make it accessible." ARIA without behaviour is a broken promise, and bad ARIA is worse than none.
outline: nonewithout a replacement focus style.- Positive
tabindexto "fix" the order instead of fixing the DOM. aria-labeleverywhere: on genericdivs, or replacing visible text with different words.- Treating a Lighthouse score of 100 as "accessible".
Senior signal
Talk about systems, not single fixes: accessible primitives in the design system (dialog, tabs, menu, combobox) so product teams do not rebuild them; lint and axe in CI plus keyboard tests for critical flows; one focus policy for route changes across the app. Name the target, usually WCAG 2.2 level AA, and the legal context where it applies, such as the European Accessibility Act, which has applied since 28 June 2025.
What to check when reviewing ARIA and focus management
Bu siyahını özün yazmadığın UI kodunda işlət: komanda yoldaşının pull request-i, kitabxananın komponenti və ya AI assistentinin təklifi. Siçanla işləyən səhifə klaviatura ilə əlçatmaz, screen reader üçün isə səssiz ola bilər, axe də bunun yalnız bir hissəsini tutur.
- Kliklənən hər element native-dirmi: əməliyyat üçün
<button>, keçid üçün<a href>?<div onclick>-in nə Tab dayanacağı, nə Enter və Space dəstəyi, nə də rolu olur. Siçanı kənara qoy və dəyişikliyi Tab ilə keç. - Hər kontrolun görünən mətnini ehtiva edən mənalı adı varmı? Hesablanmış ada DevTools-un Accessibility panelində bax; sadəcə "button" və ya ekrandakı yazıdan fərqli ad screen reader və səslə idarəetmə istifadəçiləri üçün işləmir.
- Hər
rolehəmin rolun davranışı ilə birlikdə gəlirmi? ARIA yalnız accessibility tree-nin nə bildirdiyini dəyişir:div-dəkirole="button"-a yenə dətabindex="0", Enter və Space lazımdır. - Fokus həmişə görünürmü? Əvəzində başqa fokus stili verilməyən
outline: noneaxtar, fokusu:focus-visibleilə stilləşdir və sticky header-in fokuslanmış elementi gizlətmədiyini yoxla. - Nəsə açılanda, bağlananda və ya silinəndə fokus hara gedir? Fokusdakı element silinəndə
document.activeElement<body>olur və növbəti Tab səhifənin lap əvvəlindən başlayır. Hər əməliyyatdan sonradocument.activeElement-i konsola çıxar; bağlanan menyu fokusu öz trigger-inə qaytarmalıdır. - ARIA state-ləri UI-ı izləyirmi?
aria-expanded,aria-selectedvəaria-pressedUI-ı idarə edən state-dən gəlməlidir. Kontrolun vəziyyətini dəyiş və Accessibility panelinə bax. - Tab ardıcıllığı vizual sıraya uyğundurmu, görünməyən məzmunda dayanacaq yoxdurmu? Müsbət
tabindexbütün səhifənin sırasını dəyişir, CSSorderyalnız blokların yerini dəyişir, fokus isə izləyir;opacity: 0və yaaria-hiddenilə gizlədilmiş məzmun da fokus almağa davam edir.
Use this list on UI code you did not write: a teammate's pull request, a library component or an AI assistant's suggestion. A page that works with a mouse can still be unreachable by keyboard or silent for a screen reader, and axe catches only part of it.
- Is every clickable element native:
<button>for actions,<a href>for navigation? A<div onclick>gets no Tab stop, no Enter or Space and no role. Put the mouse aside and Tab through the change. - Does every control have a meaningful name that contains its visible text? Read the computed name in the DevTools Accessibility panel; a bare "button", or a name unlike the label on screen, fails screen reader and voice control users.
- Does every
rolecome with that role's behaviour? ARIA only changes what the accessibility tree reports:role="button"on adivstill needstabindex="0", Enter and Space. - Is focus always visible? Look for
outline: nonewith no replacement; style:focus-visibleinstead, and check that a sticky header never hides the focused element. - When something opens, closes or is removed, where does focus go? Removing the focused element leaves
document.activeElementon<body>, so the next Tab starts from the top. Logdocument.activeElementafter each action; a closed menu should return focus to its trigger. - Do ARIA states follow the UI?
aria-expanded,aria-selectedandaria-pressedmust come from the state that drives the UI. Toggle the control and watch the Accessibility panel. - Does the Tab order match the visual order, with no stops on invisible content? Positive
tabindexreorders the whole page, CSSordermoves only the boxes while focus follows the , and content hidden withopacity: 0oraria-hiddenstays focusable.
Check your understanding
Practise this
Hands-on work that uses this topic.