Chapter 1 of ?
html 8 min read

HTML Mastery — Chapter 11: Form Elements & Input Types

Accessibility & ARIA

Web accessibility (a11y) ensures websites are usable by people with disabilities. HTML is the foundation — ARIA fills the gaps when native semantics aren't enough.

🌍 Who benefits?

~1.3 billion people worldwide have a disability. Includes visual, hearing, motor, cognitive impairments — plus temporary impairments like a broken arm or bright sunlight.

⚖️ Legal requirement

WCAG 2.1 AA is legally required for government and public sector websites in many countries (ADA, EN 301 549, Accessibility Act). Failure can lead to lawsuits.

📈 SEO benefit

Search engines are essentially blind users — they crawl text. Good semantic HTML and accessible descriptions directly improve search rankings.

🎯 Everyone benefits

Captions help non-native speakers. High contrast helps in bright sunlight. Keyboard navigation helps power users. Good a11y = good UX.

WCAG 4 Core Principles (POUR)

PrincipleMeaningHTML Techniques
PerceivableInformation must be presentable to all users in ways they can perceive.alt text on images, captions on video, sufficient color contrast, don't convey info by color alone.
OperableUI components must be operable.Full keyboard navigation, visible focus indicators, no keyboard traps, no seizure-inducing content, skip navigation links.
UnderstandableInformation and operation must be understandable.Set lang attribute, clear error messages, consistent navigation, predictable behavior.
RobustContent must be robust enough to be interpreted by assistive technologies.Valid semantic HTML, ARIA attributes, proper DOM structure.

Rule #1: Native HTML First

Native HTML elements have built-in accessibility. Always prefer them over custom implementations + ARIA.

✅ DO — Use native elements

<button>Submit</button>
<input type="checkbox">
<nav>...</nav>
<label for="name">Name</label>

❌ DON'T — Recreate with divs + ARIA

<div role="button" tabindex="0">Submit</div>
<div role="checkbox" tabindex="0">
<div role="navigation">
<div id="name-label">Name</div>

ARIA Landmark Roles

Landmark roles create navigation landmarks that screen reader users can jump between. Most map to native HTML5 elements:

ARIA RoleNative EquivalentPurpose
role="banner"<header> (at page level)Site-wide header. Only one per page.
role="navigation"<nav>A collection of navigation links.
role="main"<main>The primary content of the document. Only one per page.
role="complementary"<aside>Supporting content related to the main content.
role="contentinfo"<footer> (at page level)Information about the page (copyright, privacy policy, contact). One per page.
role="search"<search>A search landmark.
role="form"<form> (with aria-label)A form landmark. A <form> only creates a landmark if it has an accessible name.
role="region"<section aria-label="...">A perceivable landmark. Must have an accessible name (aria-label or aria-labelledby).

Essential ARIA States & Properties

AttributeValuesUse Case
aria-labelStringAccessible name for elements with no visible label. E.g., icon-only buttons: <button aria-label="Close"><i class="fa fa-x"></i></button>
aria-labelledbyID(s)Points to one or more elements whose text content is the accessible name. Overrides aria-label.
aria-describedbyID(s)Points to elements providing additional description. E.g., password requirements, error messages.
aria-hiddentrue/falsetrue: removes from accessibility tree (decorative icons). false: includes hidden elements.
aria-liveoff/polite/assertiveDynamic content regions. polite: announces after current speech. assertive: interrupts immediately.
aria-atomictrue/falseWith aria-live: true = announce entire region when any part changes.
aria-relevantadditions/removals/text/allWhat type of live region changes to announce.
aria-expandedtrue/false/undefinedWhether a collapsible element (accordion, dropdown) is open or closed.
aria-selectedtrue/false/undefinedWhether an item in a listbox, tab list, or tree is selected.
aria-checkedtrue/false/mixedChecked state of a custom checkbox or radio. mixed = indeterminate.
aria-pressedtrue/false/mixedPressed state of a toggle button.
aria-disabledtrue/falseMarks element as disabled in accessibility tree without removing from tab order.
aria-invalidtrue/false/grammar/spellingMarks a form field as having an invalid value. Use with aria-describedby pointing to the error message.
aria-requiredtrue/falseIndicates required field when native required attribute can't be used.
aria-currentpage/step/location/date/time/trueIndicates the current item within a set. Use aria-current="page" for active nav links.
aria-busytrue/falseIndicates a region is loading. Screen readers wait before announcing content.
aria-modaltrue/falseOn dialog/modal elements — tells screen readers the background is inert.
aria-haspopuptrue/menu/listbox/tree/grid/dialogIndicates the element can open a popup of the specified type.
aria-ownsID(s)Defines a parent-child relationship when DOM structure doesn't match visual structure.
aria-controlsIDIdentifies the element(s) this element controls.
aria-posinsetIntegerPosition of the element within a set. Used with aria-setsize.
aria-setsizeIntegerTotal number of items in the set.
aria-levelInteger (1-6)Hierarchical level for tree items or headings when native headings aren't used.
aria-placeholderStringShort hint for a custom text field (mirrors native placeholder).
aria-valuemin/max/nowNumberFor sliders, spinners, and progress bars — minimum, maximum, and current values.
aria-valuetextStringHuman-readable text for the current value. Use instead of aria-valuenow when number is not meaningful alone (e.g., "Monday" for a day picker).

Skip Navigation Link Pattern

<!-- Add as very first element in <body> --> <a href="#main-content" class="skip-link">Skip to main content</a> <!-- CSS to hide it until focused --> <style> .skip-link { position: absolute; top: -40px; left: 0; background: #4F46E5; color: white; padding: 8px; z-index: 100; transition: top 0.2s; } .skip-link:focus { top: 0; } </style> <main id="main-content">...</main>

Chapter Summary

  • Always prefer native semantic HTML over ARIA overrides — ARIA is a last resort
  • Every image needs alt; every video needs <track> for captions
  • Add aria-label to icon-only buttons so screen readers can identify them
  • Use aria-live="polite" for dynamic content updates (loading states, notifications)
  • Add a "Skip to main content" link as the first element for keyboard navigation
Done with this chapter?
Mark it complete to track your progress and unlock your certificate.
Next Up

Learner Reviews

Write a Review
Share your experience to help other learners.
Your Rating *