UI names: calling each piece by its name

A shop's orders page, built one piece at a time. Each piece gets three names: the word people use, the HTML element it's made of, and the role a screen reader hears. Then the five things that float on top of a page, and four things people call a dropdown.

Level: BasicWatch: 22 steps · ~2 minutesOpen and close the five yourselfRecall: 3 questions · 8 cardsCompare 5 things on top · 4 dropdownsHTML

What you'll take away

  • Build a page from real landmarks: <header>, <nav>, <main> and <footer>
  • Name each piece three ways: the word people say, its HTML element and its role
  • Tell a modal, a sheet, a popover, a tooltip and a toast apart by what they block
  • Know which dropdown you need: a select, a menu button, a disclosure or a combobox

The 1-minute version

Tap a point and the picture below plays that step.

4Compare them all
Header: the top bar<header>

Header<header>role: banner

<header> → …
Step 1 / 22 · step by step
0 / 22pieces named
usablethe page behind
—focus on

The picture: a big screen in the square shows a shop's back-office orders page. Each step adds one piece, which puts up its name tag; the top of the screen gives its element and its role, and the screen shows the part of the page that piece is in, close enough to read. The violet frame is keyboard focus; a dimmed page is inert behind a modal. Play shows the whole page.

Step 4 · Every option at once, on one clock

Compare them all: UI names

All five get the same three moves: open, Tab, then a click outside. See which stays, where focus goes, and whether the page behind still works.

0.0 s
Modal<dialog> + showModal()not open yet

Use it when a decision that must come before anything else: confirming a payment, unsaved work

Skip it when information the page could just show, or a long form on a phone (a sheet or a page of its own)

Behaviour as the WAI-ARIA APG and HTML's <dialog> and popover give it: a modal ignores a click outside, the sheet here closes on one (closedby="any"), and the toast leaves after 4 seconds, as in the code below. Press any tile to see it large above, with when it fits.

Names you'll hear

More pieces than the picture has room for. The role is what a screen reader says; the last column is the pattern in the WAI-ARIA Authoring Practices Guide (APG) that spells out its keys, where there is one.

The wordBuilt fromRoleAPG pattern
Navbar<nav> inside the <header>navigationDisclosure, when it folds on a phone
Hamburger button<button aria-expanded>buttonDisclosure
Drawer<dialog> at the side, or <aside>dialog, or complementaryDialog (Modal) when it blocks the page
Card<article> with a headingarticlenone
Accordionheadings holding <button aria-expanded>, or <details>button, or groupAccordion
Carousel<section aria-roledescription="carousel"> with a nameregionCarousel (needs a stop button if it moves by itself)
Stepper<ol>, the current step with aria-current="step"listnone
Progress bar<progress>progressbarnone
Spinner"Loading…" in a role="status" boxstatusnone
Skeleton<div>s, with aria-busy="true" on what's loadingnonenone
Slider<input type="range">sliderSlider
Checkbox<input type="checkbox">checkboxCheckbox
Radio group<fieldset> and <input type="radio">group, radioRadio Group
Toggle button<button aria-pressed>button (pressed)Button
Chip<button> when it does something, else <span>button, or nonenone
Avatar<img alt="…">imgnone
Alert banner<div role="alert">alertAlert
Autocomplete<input role="combobox"> and a role="listbox"combobox, listboxCombobox

The first rule of ARIA is to use the HTML element that already does the job: a <button> brings its role, its focus and its keys. ARIA roles are for pieces HTML has no element for, like tabs, menus and tooltips, and a role changes only what a screen reader says: the keys are yours to write.

Landmarks: the page's big parts

Screen readers list a page's landmarks and jump between them: the D key in NVDA, the rotor in VoiceOver. <header> and <footer> count as banner and contentinfo only at the page's own level; inside an article, aside, main, nav or section they're just groups. Keep one <main>. A page with two navs gives each a name (aria-label="Breadcrumb", "Pagination"), so the list doesn't read "navigation, navigation". A <section> becomes a region landmark only once it has a name. <search> is the newest landmark element, in every current browser since 2023 (Chrome and Firefox 118, Safari 17).

Five things on top

PieceBuilt fromThe page behindFocus when it opensGoes away on
Modal<dialog> + showModal()inertinside it (autofocus, or its first control)a button or Esc, never a click outside
Sheeta <dialog> rising from the bottominertinside ita button, Esc, a swipe down, often a tap outside
Popoverthe popover attributeusablestays put, unless you move it (a menu moves it to its first item)Esc, a click outside, another popover opening
Tooltiprole="tooltip" + aria-describedbyusablestays on its buttonfocus or the pointer leaving, Esc
Toasttext in a role="status" boxusabledoesn't moveits own timer

<dialog> with showModal() does a modal's work for you: the rest of the page goes inert, a ::backdrop covers it, Esc closes it, and focus goes back to what had it before (the snippet checks each in Chrome). A form with method="dialog" closes it and sets returnValue to the button pressed. The closedby attribute picks what else closes it: any (a click outside too), closerequest (Esc, a modal's default) or none; Chrome (134) and Firefox (141) have it, Safari not yet. The command and commandfor attributes open one with no script, in every current browser since December 2025.

The popover attribute puts an element in the top layer, above everything, without blocking the page. popover="auto", the default, closes on Esc or a click outside, and opening another one closes the first unless it sits inside it. A button with popovertarget opens it with no script; the snippet still sets aria-expanded and moves focus to the first item on the toggle event, as the APG's menu button does.

A tooltip's rules

A tooltip is a short description of the control that has focus or the pointer: role="tooltip", pointed at by the control's aria-describedby, never focused itself. WCAG 1.4.13 (level AA) asks three things of anything that shows on hover or focus: it can be dismissed without moving the pointer or focus (Esc), the pointer can move onto it without it vanishing, and it stays until one of those happens. The APG still marks its tooltip pattern as work in progress. Touch screens have no hover, so nothing should be said only in a tooltip.

Saying something without moving focus

role="status" is a polite live region: the screen reader reads its new text when it's free, and focus stays where it is, which is how WCAG 4.1.3 (level AA) wants status messages told. role="alert" is assertive and interrupts at once, so keep it for what's urgent. A status box must be in the page before its text changes: one created with its text already inside may not be read at all. A toast holding the only Undo is a trap: it can be gone before a keyboard or screen reader user gets there, so put that action on the page too.

Four things called a dropdown

PieceBuilt fromYou getKeys (APG)
Select<select>one valueopens on Space, arrows move, Enter picks (varies a little by browser and system)
Menu button<button aria-haspopup="menu"> + role="menu"an action runsEnter opens on the first item, arrows move, Enter runs, Esc closes
Disclosure<button aria-expanded> + linksanother pageEnter opens, Tab moves through the links
Combobox<input role="combobox"> + role="listbox"a value found by typingtype, then ↓ into the list, Enter picks

The APG builds a site's navigation menu as a disclosure, a button and plain links. role="menu" is for a list of actions, like an app's, and it changes both what a screen reader says and which keys work, so a site menu made of it surprises the people who rely on it.

What the picture leaves out

popover="hint" is meant for tooltips: it opens without closing a menu that's open (not in Safari yet). The interestfor attribute shows a popover on hover or focus with no script (only Chrome so far). CSS anchor positioning places a popover next to its button (not in Firefox yet), which is why the snippets place theirs with plain CSS. A menubar (File, Edit, View along the top of an app), tree views, grids you edit cell by cell and date pickers each have an APG pattern of their own that the picture has no room for.

In real code

dialog.html
<!doctype html>
<html lang="th">
<head>
  <meta charset="utf-8">
  <style>
    dialog::backdrop { background: rgb(0 0 0 / 0.4); }
  </style>
</head>
<body>
  <h1>คำสั่งซื้อ</h1>
  <!-- commandfor + command="show-modal" open the dialog with no JavaScript (in every major browser since Dec 2025). -->
  <button id="open" commandfor="export" command="show-modal">Export</button>
  <a href="#help">ช่วยเหลือ</a>

  <!-- A modal dialog: until it closes, the rest of the page is inert. Esc closes it. -->
  <dialog id="export" aria-labelledby="export-title">
    <h2 id="export-title">Export คำสั่งซื้อ 42 รายการ</h2>
    <p>เป็นไฟล์ CSV</p>
    <!-- method="dialog": either button closes the dialog, and its value becomes returnValue. -->
    <form method="dialog">
      <button value="cancel">ยกเลิก</button>
      <button value="export" autofocus>Export</button>
    </form>
  </dialog>

  <script>
    const dialog = document.getElementById("export");
    // When it closes, the browser puts focus back on the button that opened it; here we only read the answer.
    dialog.addEventListener("close", () => {
      if (dialog.returnValue === "export") console.log("export orders.csv");
    });
  </script>
</body>
</html>
Run: open in a browser (checked in headless Chrome: dialog.expect.json)It printed: Export pressed: the dialog opens as a modal · focus is on the dialog's Export button (autofocus) · the link behind can't take focus (inert) · Export answered: the dialog closes, returnValue is export, and focus is back on the button that opened it

A button with command="show-modal" opens the dialog with no script, autofocus puts focus on Export, and a form with method="dialog" closes it with a returnValue. Opened in headless Chrome: it's modal, the link behind it can't take focus, and focus comes back to the button. Really run; below is what it printed.

Common questions

What's the difference between a modal, a popover and a toast?

A modal asks and waits: the page behind is inert and a click outside doesn't close it. A popover floats by the button that opened it, the page still works, and a click outside or Esc closes it. A toast asks nothing: it says something finished, takes no focus, and goes away by itself.

Table: five things on top

What are landmarks, and why use <header>, <nav> and <main> instead of divs?

Landmarks are the big parts of a page a screen reader lists and jumps to, like skipping the menu to the content. HTML elements bring the role with them: header is banner, nav is navigation, main is main and footer is contentinfo. A div has no role at all.

Read: landmarks

Is a dropdown a <select>?

Sometimes. People call four things a dropdown: a <select> picks one value, a menu button opens a list of actions, a disclosure shows and hides a group of links, and a combobox is a field you type into with a list. Each has its own keys, and screen readers hear a different role.

Read: four dropdowns

Should a modal close when you click outside it?

Not one that asks something important: a stray click would lose the work. A <dialog> opened with showModal() closes on Esc but not on a click outside. A sheet on a phone often closes on a tap outside (closedby="any" in Chrome and Firefox).

When should I use a tooltip?

For a short label on a button, like an icon button. It shows on hover or focus of its button and must be dismissible without moving the pointer or focus, like with Esc (WCAG 1.4.13). It can't take focus, so it can't hold a link or a button, and touch screens have no hover. Anything people must read or press belongs on the page or in a popover.

Read: a tooltip's rules

How do I tell screen reader users something finished without moving focus?

Put the text in a role=status box that was in the page from the start: the screen reader reads it when it's free, and focus doesn't move (WCAG 4.1.3). A box created along with its text may not be read at all. Keep role=alert for what's urgent, because it interrupts at once.

Read: telling without moving focus

What do you call the grey shapes shown while data loads?

A skeleton: the shape of the data that's coming, so the page doesn't jump when the real rows replace it. It has no role of its own: put aria-busy="true" on the part that's loading and take it off when it's done.

Table: names you'll hear

If I use the right HTML, do I still need ARIA roles?

Mostly not. The first rule of ARIA is to use the HTML element that already does the job: a <button> brings its role and its keys. ARIA is for pieces with no matching element, like tabs, menus and tooltips, and then you write the keyboard part yourself.

Table: names you'll hear

Next lesson

Flexbox vs GridLevel: Basic

Every piece has a name now; next, laying them out on the page with Flexbox and Grid, one axis or two.