HTML Semantics for UI Components: 10 Tags That Make Reusable Components More Accessible

November 18, 2026

When you build a reusable component library, the first API decision is usually not the prop name. It is the HTML element underneath. A component named Button can render a real <button>, a clickable <div>, or a router link styled like a button. Those choices affect keyboard support, screen-reader output, focus behavior, form participation, and the CSS hooks your users can rely on.

accessible web components

Native semantics will not solve every accessibility issue, especially for complex widgets, but they remove a lot of work you would otherwise recreate with JavaScript. Here are ten tags and patterns I reach for when building common UI components.

1. <button>: the default action element

Use <button> for any clickable control that triggers an action in place: opening a menu, submitting a form, dismissing a toast, copying text, or toggling a disclosure. It is focusable, activates with Enter and Space, participates in forms, and is announced as a button by assistive tech.

A styled <div onclick> gives you none of that. If you must add a click handler to a non-interactive element, you are already paying the cost of recreating button semantics.

For reusable buttons, expose the semantic variant through props instead of changing the element casually:

  • Submit or action: <button type="button"> or type="submit"
  • Navigation: <a href="...">
  • Toggle state: aria-pressed="true|false"
  • Expanded state: aria-expanded="true|false"

Keep type="button" explicit for action buttons inside forms. Otherwise, a button without a type can submit the form unexpectedly.

html code editor screen

2. <a>: navigation is different from an action

Use an anchor when the component changes the URL, opens a resource, or shares a location. The href attribute is what makes it a real link: it is keyboard-focusable, appears in the links list, and supports opening in a new tab.

A common component-library mistake is one Button component that renders either a button or a link. That is fine, but preserve the semantics. A link styled as a pill still behaves like a link; a button styled as text still performs an action.

For styling, use a shared visual class rather than relying on the tag name:

.btn { /* shared surface styles */ }
button.btn { /* optional control-specific tweaks */ }
a.btn { /* optional link-specific tweaks */ }

3. <dialog>: native dialog structure, with one important caveat

The native <dialog> element gives you a semantic dialog surface and the showModal() API. Modal dialogs opened with showModal() provide a top layer, focus trapping behavior, and a backdrop you can style with ::backdrop.

That is a strong starting point for confirmations, short forms, and lightboxes. Still, a polished accessible dialog needs component-level rules:

  1. Give the dialog an accessible name with aria-labelledby or aria-label.
  2. Move focus to a sensible control on open.
  3. Return focus to the trigger on close.
  4. Close on Escape when appropriate.
  5. Prevent interaction with obscured page content.

Do not place all page content in a dialog just to get the top layer. Use it for a true blocking task.

4. <nav>: mark major navigation groups

Use <nav> around groups whose primary purpose is navigation: primary menus, sidebars, breadcrumbs, and pagination. Screen readers can list and jump to navigation landmarks, which is much faster than tabbing through every link.

Because landmarks become noise when overused, label multiple nav regions distinctly:

<nav aria-label="Primary">...</nav>
<nav aria-label="Breadcrumb">...</nav>
<nav aria-labelledby="toc-heading">...</nav>

Breadcrumbs can use aria-label="Breadcrumb" on the nav and an ordered list inside. The list communicates sequence without requiring extra widget semantics.

5. <ul>, <ol>, and <li>: give repeated items structure

Lists are one of the most practical accessibility hooks in component libraries. Menus, sidebars, breadcrumbs, checklists, file rows, and option groups often map naturally to list markup.

Use <ul> when item order does not matter and <ol> when sequence matters. Screen readers can announce the number of items and the user's position, and designers can use list-specific pseudo-elements for markers without polluting markup.

If you remove default bullets with CSS, keep the semantic list unless the visual grouping is truly trivial. You can reset spacing without removing the element:

.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

6. <section> with an accessible name: a labelled region, not a styled box

A <section> is only a landmark when it has an accessible name. That makes it useful for components such as account settings, dashboard panels, and filter panels that users may want to jump to.

<section aria-labelledby="filters-title">
  <h2 id="filters-title">Filters</h2>
</section>

If the box is purely visual and has no meaningful heading, a plain <div> is often more honest. Do not wrap every card in a section just to get a generic container.

Headings also matter inside reusable components. Let consumers choose the heading level or provide a headingLevel prop. A card component that hard-codes <h2> can easily break the document outline when it appears inside a subsection.

7. <label>: connect every control to its name

Form components are where reusable abstractions most often fail users. Every input needs a programmatically associated label. The cleanest pattern is wrapping the label and control, but generated IDs are also reliable in component frameworks.

<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email" />

A placeholder is not a substitute for a label. It disappears while typing and often fails to describe the field clearly enough.

For composite inputs, use the outer label for the field name and aria-describedby for helper text or validation messages. Keep error messages tied to the input so they are announced when the field receives focus.

8. <fieldset> and <legend>: group related controls

Use a <fieldset> for groups where the individual labels are incomplete without a shared question. Radio groups, checkbox groups, date segments, and shipping-option groups are common examples.

<fieldset>
  <legend>Shipping method</legend>
  <label><input type="radio" name="ship" value="standard" /> Standard</label>
  <label><input type="radio" name="ship" value="express" /> Express</label>
</fieldset>

Fieldsets can be difficult to style across browsers, but they are worth preserving. Reset margin, padding, and border on the fieldset, then style an inner wrapper if you need a polished card or row layout.

9. <output> and <progress>: expose dynamic values

Some components update as the user works. Native elements can communicate that state without turning every change into a live-region announcement.

Use <output> for the result of a calculation or user action, such as a price estimate, character count, or slider-derived value:

<label for="amount">Amount</label>
<input id="amount" type="range" min="0" max="100" />
<output for="amount" id="amount-value">50</output>

Use <progress> for completion toward a known total, such as file upload progress. Include max and the current value. For an unknown-duration loading state, aria-busy="true" on the waiting container may be more appropriate than a progress bar.

10. <aside> and complementary landmarks

Use <aside> for content that supports the main content but can be understood separately: related articles, product summaries, saved filters, or a cart preview. When labelled, it becomes a complementary landmark.

Be careful with sidebars in application shells. If the aside contains primary navigation, the navigation itself should be a <nav>. The layout container and the semantic role do not have to be the same element.

Tabs, alerts, and toasts: choose semantics carefully

Not every common component has a single dedicated HTML tag.

For tabs, the robust pattern uses tab buttons with role="tab", a tablist, and tab panels, plus arrow-key navigation. Before reaching for that pattern, ask whether the content would work better as a simple list of in-page links and headings. Tabs hide content and add keyboard complexity.

For important inline feedback, use role="alert" sparingly. It creates an assertive live region and is useful when a form submission fails or a destructive action cannot proceed. For less urgent toasts, role="status" is usually calmer. Include a close button, keep messages concise, and avoid stealing focus unless the message requires a decision.

For menus, distinguish website navigation from application menus. A list of links should usually remain links in a <nav> or <ul>. The menubar, menu, and menuitem roles come with arrow-key expectations borrowed from desktop software; they are appropriate for context menus and toolbars, not every dropdown link list.

Use semantic tags as style hooks

Semantic markup also makes CSS easier to reason about. Instead of adding classes such as .is-dialog or .is-nav, style the element directly where appropriate:

dialog::backdrop {
  background: rgb(15 23 42 / 55%);
}

nav ul {
  display: flex;
  gap: .75rem;
}

label:has(:user-invalid) {
  color: #b91c1c;
}

Keep presentational classes for visual variants such as size, tone, and elevation. Let the element communicate behavior; let classes communicate design.

Practical checklist before shipping a component

  • Can you reach and activate it with the keyboard alone?
  • Does its announcement match its behavior: button, link, checkbox, dialog, navigation, or status?
  • Is focus visible and managed during openings, closings, and route changes?
  • Are labels, legends, descriptions, and error messages programmatically connected?
  • Do dynamic updates announce at the right urgency?
  • Can the component be styled without removing native behavior?

The best reusable components do not merely look consistent. They carry the correct native contract into every product screen. Start with the HTML element that already does the most work, then add ARIA only where the native language falls short.