Semantic HTML for UI Components: 9 Elements You Should Stop Replacing With <div>

November 19, 2026

Quick decision table

Pick the element from the user's task, not the visual shape.

web developer code screen
UI componentReach forBuilt-in behaviorAvoid
Button<button>Focus, Enter/Space activation, form hooks<div onclick>
Card link<a>, often with <article>Navigation, modified click, href contextClickable whole-card div
Modal<dialog>Top layer, Escape, backdrop, initial focusCentered div with manual focus traps
Navigation tabs<nav> + linksURL navigation, landmarksTab-looking divs without routing
ARIA tabstablist/tab/tabpanelPattern expected by assistive techHalf-built div buttons
Filter/menu trigger<button> + disclosure/menu patternFocus and expanded stateHover-only div panel
Form controls<input>, <select>, labelsName/value, state, validation, keyboard UIStyled div pretending to be a field
Lists<ul>/<ol>List structure and navigationStacked divs for repeated items
Data/media<table>, <figure>, <blockquote>Headers, captions, attribution relationshipsGrid divs carrying semantic data
accessible web form

1. Buttons: use <button> for actions

Use for

Submit forms, open menus, toggle filters, copy text, or trigger JavaScript without changing the URL.

Avoid

<div class="btn" onclick="save()">Save</div>

The div is not focusable, has no button role, and does not respond to Enter or Space. You also lose modified-click behavior, disabled handling, and form association.

Recommended

<button type="button" class="btn" onclick="save()">Save</button>
<button type="submit">Publish</button>

Accessibility notes

A native button gives focusability, the button role, Space/Enter activation, disabled, and participation in form submission. If it opens a panel, pair it with aria-expanded.

2. Links and articles: use <a> for destinations and <article> for self-contained cards

Use for

Product cards, article previews, dashboard tiles, and anything that routes to another page or resource.

Avoid

<div class="card" onclick="goTo('/post')">
  <h3>CSS grid pattern</h3>
</div>

A clickable card div loses the link role, href destination, open-in-new-tab, Ctrl/Cmd-click, Shift-click, bookmarking, and keyboard activation.

Recommended

<article class="card">
  <h3><a href="/posts/css-grid">CSS grid pattern</a></h3>
  <p>A practical layout recipe.</p>
</article>

Accessibility notes

Use a stretched link only when the whole card should navigate. Keep secondary links separate, or nested clicks become ambiguous. <article> communicates a self-contained piece; do not use it purely for visual boxes.

3. Modals: use <dialog> for top-layer dialogs

Use for

Confirmations, lightboxes, short forms, and focused task windows.

Avoid

<div class="modal is-open" role="dialog">...</div>

A plain div starts with no stacking guarantee, no backdrop, no Escape handling, and no focus management. Reproducing all of that manually is where bugs accumulate.

Recommended

<dialog id="confirm">
  <form method="dialog">
    <h2>Delete item?</h2>
    <button value="cancel">Cancel</button>
    <button value="confirm">Delete</button>
  </form>
</dialog>
confirm.showModal();

Accessibility notes

showModal() opens a modal dialog in the top layer, provides ::backdrop, supports Escape to close, and moves initial focus to a button or other focusable control. Still test focus order, focus trapping, closing behavior, and focus restoration after close. When needed, ensure background content cannot be interacted with and give the dialog an accessible name.

4. Navigation tabs: use <nav> and links for URL-based sections

Use for

Section navigation, routed pages, settings pages where each tab has a URL, and links that work without JavaScript.

Avoid

<div class="tabs">
  <div class="tab active">Overview</div>
</div>

The div stack gives no landmark, no destination, no current-page semantics, and no keyboard navigation beyond whatever you manually rebuild.

Recommended

<nav aria-label="Account sections">
  <ul>
    <li><a href="/account" aria-current="page">Overview</a></li>
    <li><a href="/account/billing">Billing</a></li>
  </ul>
</nav>

Accessibility notes

Do not confuse visual tabs with ARIA tabs. If selecting an item changes the URL or loads a page region, links are the simpler, robust choice.

5. Stateful panels: use the ARIA tabs pattern only for no-refresh panels

Use for

A single-page tabbed interface where one panel is shown while others remain hidden and users expect the tabs interaction model.

Avoid

<div class="tab" onclick="showPanel(1)">Shipping</div>

That div lacks role="tab", selected state, panel relationship, roving focus, and Left/Right Arrow navigation.

Recommended

<div role="tablist" aria-label="Order details">
  <button role="tab" id="shipping-tab" aria-controls="shipping-panel" aria-selected="true">Shipping</button>
  <button role="tab" id="returns-tab" aria-controls="returns-panel" aria-selected="false" tabindex="-1">Returns</button>
</div>
<section role="tabpanel" id="shipping-panel" aria-labelledby="shipping-tab" tabindex="0">...</section>

Accessibility notes

Implement the complete pattern: roving tabindex, Arrow keys, Home/End, aria-selected, and panel focus behavior. If that is overkill, use a navigation landmark with links instead.

6. Menus, filters, and disclosures: use a button with the correct ARIA pattern

Use for

Sort dropdowns, filter popovers, account menus, and “more options” controls.

Avoid

<div class="menu-trigger" onmouseover="open=true">Sort</div>

Hover-only divs fail keyboard users, hide the trigger from assistive tech, and communicate neither expanded state nor ownership of the panel.

Recommended

<button type="button" aria-expanded="false" aria-controls="sort-menu">Sort</button>
<div id="sort-menu" hidden>
  <button type="button">Price: low to high</button>
</div>

Accessibility notes

For site navigation, links are usually enough. For application-like command menus, use menu, menuitem, and the expected keyboard model only if you are prepared to implement it fully. A disclosure button is often the simpler accessible pattern for filters.

7. Checkboxes and radios: use <input> for binary and single-select state

Use for

Agreement boxes, table row selection, feature toggles that represent a form value, and choose-one groups such as shipping method.

Avoid

<div class="checkbox checked" onclick="toggle()">Gift wrap</div>

The div loses the checkbox role, checked state, focus ring, Space toggle, native label activation, form submission, and browser validation. A radio group additionally loses shared name grouping and single-selection behavior.

Recommended

<label>
  <input type="checkbox" name="giftWrap" value="yes">
  Gift wrap
</label>

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

Accessibility notes

Style the native input with :checked, accent-color, or a visually positioned custom control; do not remove it. Use fieldset/legend when radios need a group question. A switch-like visual does not automatically make the control a switch; use role="switch" only when the semantics are truly on/off rather than checked/unchecked.

8. Form fields and selects: use <label>, <input>, and <select> for data entry

Use for

Search filters, settings forms, country pickers, date fields, and any component that submits a named value.

Avoid

<div class="select">Selected: United States</div>
<div class="input" contenteditable="true"></div>

These constructions have no reliable name/value, no form association, no required or invalid state, no autocomplete, no mobile input type, and no native selection UI.

Recommended

<label for="country">Country</label>
<select id="country" name="country" required>
  <option value="US">United States</option>
  <option value="CA">Canada</option>
</select>

Accessibility notes

Every field needs a persistent label; placeholder text is not a replacement. Native <select> is especially strong on keyboards and touch devices. Build a custom combobox only when you need search, multiselect, or rich options and can implement the full ARIA pattern, including collapsed/expanded state, active descendant, typeahead, and Escape.

9. Lists, tables, quotes, and figures: use structure that matches the content

Use for

Repeated UI items, tabular data, pull quotes, diagrams, screenshots, and images with captions.

Avoid

<div class="table">
  <div class="row"><div>Invoice</div><div>Status</div></div>
</div>

A grid of divs does not expose row and header relationships. A pile of divs also gives list navigation no structure, and quoted media gets no relationship between content and caption or citation.

Recommended

<ul>
  <li>Design tokens</li>
  <li>Dark mode</li>
</ul>

<table>
  <caption>Open invoices</caption>
  <thead><tr><th scope="col">Invoice</th><th scope="col">Status</th></tr></thead>
  <tbody><tr><td>1042</td><td>Paid</td></tr></tbody>
</table>

<figure>
  <img src="tokens.png" alt="Color tokens listed in a design tool." width="800" height="450">
  <figcaption>Primitive tokens feed semantic component tokens.</figcaption>
</figure>

<blockquote cite="/guidelines/color">
  <p>Never bind components directly to raw color values.</p>
</blockquote>

Accessibility notes

Screen readers can recognize list structure and provide navigation; exact announcement depends on settings and browsing mode, so do not add list roles solely to force a count. Tables are for data relationships, not generic layout. Use figure when a caption belongs with media, and blockquote for a quotation, not merely for indentation.

When a div is still acceptable

Use a <div> for pure layout wrappers, spacing utilities, decorative layers, scroll containers, and styling hooks that carry no meaning. The rule is simple: if the element is operable, navigable, stateful, quoted, tabular, or grouping related form controls, choose the native element or complete the ARIA pattern. If it only helps CSS, a div is fine.