KodingKaro
HTML · Advanced · Accessibility Engineering

Accessible names, states, and testing

An accessible interface communicates not only what a control is called but also its current state and how to operate it.

✓ What you will learn in this topic

  • Explain the purpose of Accessible names, states, and testing in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

Accessible-name computation combines sources such as associated labels, element text, and ARIA naming attributes according to defined rules. Prefer visible labels because they support more people and remain discoverable. ARIA state attributes such as aria-expanded must reflect the actual interface state. Test with keyboard-only interaction, browser accessibility inspection, and representative screen readers; automated scans find some issues but cannot judge every task or label.

Syntax

Keep visible text and programmatic names aligned; update ARIA state whenever the corresponding UI state changes.

Example 1: a small page

The name comes from button text; expanded state and hidden content must stay synchronized by the interaction.

<button type=\"button\" aria-expanded=\"false\" aria-controls=\"tip\">Show tip</button>
<p id=\"tip\" hidden>Save your changes before leaving.</p>

Expected result: The button announces its label and collapsed state, and its target is identifiable.

Example 2: a practical page

The label names the input and the description adds instructions without replacing the name.

<label for=\"code\">Invitation code</label>
<input id=\"code\" name=\"code\" aria-describedby=\"code-help\">
<p id=\"code-help\">Use the 8-character code from your invitation.</p>

Expected result: The control’s name and format guidance are available when navigating the form.

Common mistakes

Do not infer accessibility from the presence of ARIA attributes or a passing automated scan alone.

Best practices

Combine semantic review, keyboard testing, screen-reader checks, and automated tools with real task scenarios.

Practice exercise

Audit a multi-step checkout form and data table. Test navigation without a mouse, verify names and states with a screen reader, and record fixes.

Lesson summary

  • Accessible names and states must match the visible interface and be tested in real navigation tasks.
  • Combine semantic review, keyboard testing, screen-reader checks, and automated tools with real task scenarios.

Knowledge check

What must happen when a disclosure panel opens?

Show the explanation

The button’s aria-expanded state and the panel’s visibility must be updated to reflect the same state.

Practical example

html
<button type=\"button\" aria-expanded=\"false\" aria-controls=\"tip\">Show tip</button>
<p id=\"tip\" hidden>Save your changes before leaving.</p>

Expected result:

The button announces its label and collapsed state, and its target is identifiable.

Hands-on practice task

Audit a multi-step checkout form and data table. Test navigation without a mouse, verify names and states with a screen reader, and record fixes.

In this section

Other lessons in Accessibility Engineering

Broaden your knowledge

Related learning topics