Solice UI
Back to the curriculum

Chapter 5 · Accessibility & Interaction

Semantic roles and labels

A control needs both a role and a name. Native HTML usually supplies the role, while visible text or an associated label explains what the control will do.

Beginner · Lesson 2 of 6 in this chapter

Start with the native element

Use a button for an action, a link for navigation, and a labelled input for data entry. Native elements bring keyboard behavior and platform semantics that a generic div does not provide.

Names should match visible intent

A screen reader may announce an accessible name without nearby visual context. Keep it concise and aligned with the visible label; extra instructions belong in help text connected through a description.

Labelling a search control

  1. A label is associated with the search input by id.
  2. The clear button has its own name because it is a separate action.
  3. The result status is announced without moving focus away from the input.
  • Role says what a control is; name says what it does.
  • Native HTML is usually the shortest accessible implementation.
  • One label should not accidentally label a different nested control.