HTML elements do more than control how a page looks. Choosing elements that describe their purpose gives browsers, assistive technologies and developers a more useful foundation for understanding and maintaining a website. Semantic markup is not a substitute for testing, but it can make common interactions and page relationships clearer.
Choose elements for meaning
Use landmarks such as <header>, <nav>, <main> and <footer> to describe the broad regions of a page. Use <article> for a self-contained piece of content and <section> for a themed grouping with a heading. A generic <div> remains useful when no element expresses the role; replacing every div is not the goal.
Build controls with native elements
A real <button> already supports keyboard activation and exposes its role to assistive technology. A clickable <div> does not provide the same behavior automatically. Prefer native buttons, links, labels and form controls, then add accessible names and state information where needed. ARIA can fill specific gaps, but it should not be used to imitate a native control when the native element fits.
Write a clear heading structure
Headings help readers scan and navigate a document. Give each page a clear primary heading, use subsequent heading levels to represent nested topics, and choose wording that describes the section. Do not select a heading level just to obtain a particular font size; CSS should control appearance while the document outline reflects the content.
Test the rendered experience
Semantic markup improves the foundation, but it does not prove a page is accessible. Test keyboard focus order, visible focus, labels, validation messages, zoom and screen-reader navigation. Also check that headings and landmarks make sense in the rendered page, especially after client-side updates. For element-specific guidance, consult the MDN HTML element reference and the W3C accessibility introduction.
Use landmarks to describe page regions
A page can use a small number of landmarks to make its broad structure easier to navigate. A site header, primary navigation, main content, and footer are common examples. If a page has several navigation regions, give each a useful accessible name so a screen-reader user can distinguish them. Do not add a landmark to every visual container; too many regions can make navigation noisy rather than helpful.
Use an article element when a section can stand on its own, such as a news item or a blog post. A section groups related content and should normally have a heading. A generic div remains appropriate when no element expresses the meaning. The objective is not to eliminate generic containers but to make important relationships clear in the document structure.
Choose native controls for interactions
Use a link to navigate to another location and a button to perform an action. Native elements support browser behaviors such as keyboard activation, focus, and expected roles. A clickable span or div requires extra work to reproduce those behaviors and can still fail when disabled, loading, or focused. A visible label associated with an input is more reliable than placeholder text alone because the label remains available as the user enters data.
For a form, connect labels and controls, identify required fields in text, explain errors near the affected input, and keep the error available to assistive technology. When a button opens a menu or disclosure, expose its state and ensure the control can be activated by keyboard. Use ARIA when native HTML cannot express a necessary role or state; adding ARIA does not automatically make a custom control accessible.
Keep headings and content relationships clear
Write headings that tell a reader what the following section covers. A page should have a clear primary heading, with subsequent levels representing the actual structure rather than the desired font size. Style headings with CSS instead of selecting a heading level because it looks larger. A concise outline also helps content authors notice missing steps or sections that have no clear purpose.
Lists, tables, and figures have their own semantics. Use a list when the items form a group, and use a data table only when rows and columns express relationships. Provide a caption or header cells that explain those relationships. For an image that conveys information, provide a concise alternative text; for a purely decorative image, an empty alternative prevents a screen reader from announcing irrelevant detail. The correct choice depends on what the image contributes in context.
| Need | Prefer | Check |
|---|---|---|
| Navigate to a page or section | A link with a meaningful destination | Keyboard access and clear link text |
| Submit or change something | A button | Name, state, focus, and disabled behavior |
| Group related content | A section with a heading | Whether the group has a clear topic |
Test the rendered result, not only the source
A code review can catch invalid nesting or a missing label, but it does not prove that the rendered experience works. Test the page with a keyboard, confirm focus is visible and follows a sensible order, enlarge text, zoom, and inspect forms in both success and error states. Try at least one screen reader and verify that the accessible names and region structure make sense. Automated tools can identify some issues, but they cannot determine whether instructions are understandable or whether a task is easy to complete.
For example, a visually styled card may contain a heading and a call-to-action. If the entire card is made clickable with nested links, the resulting interaction may be confusing or invalid. Prefer a clear heading, a short description, and a distinct link to the destination. Review behavior after client-side updates as well: modals, validation messages, menus, and live results may change the accessibility tree after the initial page load.
Semantic HTML contributes useful structure and native behavior, but it is one part of accessibility. It does not replace accessible design, content review, testing with assistive technology, or ongoing maintenance. It also should not be presented as a guarantee of higher search rankings. Start with the task users need to complete, choose elements that express the content and interaction, and validate the final page against the relevant accessibility requirements. The MDN HTML element reference is a useful reference when selecting elements.
Avoid common semantic markup pitfalls
A common mistake is choosing a semantic element because its default browser styling looks convenient. An article is not simply a card, and a nav is not a generic wrapper for every set of links. Select an element based on its role, then use CSS for the presentation. Another mistake is adding ARIA roles that conflict with an element’s native role. When in doubt, start with plain HTML and inspect the accessibility tree before adding custom semantics.
Dynamic interfaces deserve special attention. When a search result count changes, ensure the update is available without forcing users to re-read the entire page. When a dialog opens, place focus appropriately and return it to the triggering control when it closes. When validation fails, identify the affected field and describe what needs correction. These behaviors depend on the complete interaction, not merely the tag name used in the initial markup.
Make semantic decisions part of code review and content authoring guidance. A short checklist—landmarks, headings, links, controls, labels, lists, and meaningful images—can prevent recurring errors. Re-run manual checks after major component updates because shared navigation, forms, and dialogs can affect many pages at once. This practice produces clearer interfaces for everyone while keeping the markup understandable to the next developer.


