Every element on the Balai’s board wears the name it is announced by: title, aria-label, content, aria-labelledby and label compete. Which one wins? The…
Why it matters
The accessible name is what a screen reader says and what a voice-control user calls out ("click Kirim"). Get it wrong and a button is read as just "button", or read differently from what is shown. Testing Library finds elements by that same name (getByRole(…, { name })).
The key idea
The browser takes ONE source, in order, and stops there
Common mistakes
The screen reader says one name while the eye reads another on the button That breaks WCAG 2.5.3 (Label in Name): when there is visible text, the name must contain it. Want more context? An aria-label="Kirim formulir" that still starts with "Kirim", or sr-only text, never a different name altogether.
Only a title to name a buttontitle does become the name when there is no other source (the last step before the placeholder), but its tooltip never shows for keyboard and touch users, and some screen readers treat it as a description. Use visible text, aria-label or sr-only text.
aria-labelledby is there, yet the button still has no name A missing id is skipped silently, with no error. Check the spelling (- vs _) and that the element pointed at is in the same document (or shadow root) and holds text. It may be hidden: aria-labelledby still reads it.
Try it in this playground
Open Icon only and click its button Every line on the neighbourhood head’s list is empty: Mr. Sugeng only hears "button".
Open aria-label ≠ textaria-label wins, the contents "Kirim" are struck out, and Wulan is startled: what she sees is not in the name.
Open Two ids joined (More examples)aria-labelledby="h3 r3": the button names itself, then its heading, so "Hapus Laporan Q3". The neighbourhood head’s string runs to the heading.
Open aria-label on a div Its plate says "aria-label ignored": Mr. Sugeng only hears the card’s text.