KodingKaro
HTML · Intermediate · Accessible HTML

Accessible names, labels, and headings

Accessible names and a clear outline let people understand controls and navigate long pages efficiently.

✓ What you will learn in this topic

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

Concept explanation

A control’s accessible name is the label announced by assistive technology. A visible label linked with for/id is a strong default for form fields. Link text should make sense in a list of links; avoid vague phrases such as click here. Headings should express the page outline in order. A skipped level may sometimes be valid for a genuine outline, but heading levels should not be chosen to imitate font sizes.

Syntax

Use visible label and heading elements; provide concise link text that names the destination or action.

Example 1: a small page

The label names the field, and the button states the action rather than relying on an icon alone.

<label for=\"search\">Search the plant guide</label>
<input id=\"search\" name=\"q\" type=\"search\">
<button type=\"submit\">Search</button>

Expected result: A clearly labeled search field and an action button are available to sighted and screen-reader users.

Example 2: a practical page

The headings form a meaningful outline and the link describes its destination.

<article>
  <h1>Native flowers for shade</h1>
  <h2>Three plants to try</h2>
  <p>Compare <a href=\"/plants/fern\">fern growing details</a> before planting.</p>
</article>

Expected result: The article can be navigated by heading, and the link remains understandable out of context.

Common mistakes

Do not use ARIA roles to imitate a native link or button when the native element already supplies the behavior.

Best practices

Prefer native HTML, visible labels, descriptive link text, logical headings, and keyboard testing before adding ARIA.

Practice exercise

Review an existing page using only the keyboard. Improve its heading order, form labels, link text, and button behavior; add ARIA only if a native element cannot express a required name or state.

Lesson summary

  • Accessible names, meaningful headings, and descriptive links communicate purpose.
  • Prefer native HTML, visible labels, descriptive link text, logical headings, and keyboard testing before adding ARIA.

Knowledge check

What is a strong way to give a text input an accessible name?

Show the explanation

Associate a visible label with the input using a matching for and id value.

Practical example

html
<label for=\"search\">Search the plant guide</label>
<input id=\"search\" name=\"q\" type=\"search\">
<button type=\"submit\">Search</button>

Expected result:

A clearly labeled search field and an action button are available to sighted and screen-reader users.

Hands-on practice task

Review an existing page using only the keyboard. Improve its heading order, form labels, link text, and button behavior; add ARIA only if a native element cannot express a required name or state.

In this section

Other lessons in Accessible HTML

Broaden your knowledge

Related learning topics