EthicsComputerCourses
Join training +91 90532 10052

Accessibility Engineering: WCAG 2.2

HTML · Lesson 93 of 234 Advanced 10 min read Updated

By the end of this lesson you will be able to read a WCAG 2.2 success criterion, say which level it belongs to, and turn it into concrete HTML. You will also build two small pages that meet new WCAG 2.2 criteria and learn how the standard connects to Indian government rules.

What you should know first: HTML Accessibility Fundamentals, ARIA Roles & Attributes and Keyboard Navigation & Focus Management. Checking a whole site against WCAG comes later in WCAG Accessibility Auditing.

What WCAG is

The Web Content Accessibility Guidelines (WCAG) are published by the W3C's Web Accessibility Initiative. They describe what makes web content usable by people with disabilities: blind and low-vision users, deaf users, people with motor, cognitive or learning disabilities, and many older users.

VersionPublishedWhat it added
WCAG 2.0December 2008The base: 4 principles, guidelines and testable success criteria
WCAG 2.1June 2018Mobile, low vision and cognitive needs, such as reflow and orientation
WCAG 2.25 October 2023Nine new criteria; 4.1.1 Parsing removed

WCAG is technology neutral. It never says "use <label>". It says what must be true, such as "labels or instructions are provided". Separate W3C documents, Understanding WCAG 2.2 and Techniques for WCAG 2.2, explain each criterion and list sufficient techniques (ways to pass) and failures (common ways to fail). The HTML techniques are where your daily work happens.

The versions are backwards compatible. A page that meets WCAG 2.2 also meets 2.1 and 2.0. WCAG 3 is still a W3C working draft, so do not use it for conformance yet.

The POUR principles

All success criteria sit under four principles. Think of an accessible railway station.

PrincipleMeaningAt the stationOn a web page
PerceivableUsers can sense the contentAnnouncements and display boardsalt text, captions, contrast
OperableUsers can work the interfaceRamps, lifts, wide gatesKeyboard access, enough time, no traps
UnderstandableUsers can follow content and controlsClear, consistent signsLabels, clear errors, predictable behaviour
RobustWorks with many tools, now and laterPlatforms that fit every trainValid roles, names and states for assistive technology

Under the principles are 13 guidelines (for example 1.4 Distinguishable), and under those the success criteria, numbered like 1.4.3. Only success criteria are tested.

Levels A, AA and AAA

Every success criterion has a level:

  • Level A: the minimum. Without it, some people cannot use the page at all. Example: 1.1.1 Non-text Content (text alternatives).
  • Level AA: removes major barriers. Example: 1.4.3 Contrast (Minimum), 4.5:1 for normal text.
  • Level AAA: the highest. Example: 1.4.6 Contrast (Enhanced), 7:1.

Levels add up. AA conformance means meeting every A and every AA criterion. AA is what laws and policies around the world usually require. The W3C does not recommend AAA as a policy for whole sites, because some content cannot meet every AAA criterion, but individual AAA items are worth adopting where you can.

Conformance applies to full pages and complete processes. A checkout that is accessible except for the payment step does not conform.

What is new in WCAG 2.2

CriterionLevelWhat it asksHTML and CSS technique
2.4.11 Focus Not Obscured (Minimum)AAA focused element is not fully hidden by author contentscroll-padding for sticky bars; dismissible banners
2.4.12 Focus Not Obscured (Enhanced)AAANo part of it is hiddenSame, with more space
2.4.13 Focus AppearanceAAAA large, high-contrast focus indicatorA solid :focus-visible outline, at least 2px
2.5.7 Dragging MovementsAAAnything done by dragging can also be done with single clicks or tapsButtons next to sliders, sortable lists and maps
2.5.8 Target Size (Minimum)AATargets at least 24 by 24 CSS pixels, or spaced outPadding on links and buttons
3.2.6 Consistent HelpAHelp links appear in the same relative place on each pageA shared header or footer template
3.3.7 Redundant EntryADo not make users type the same information twice in one process"Same as delivery address", prefilled values
3.3.8 Accessible Authentication (Minimum)AALogin does not depend on a memory or puzzle test without helpAllow paste and password managers, autocomplete
3.3.9 Accessible Authentication (Enhanced)AAAAs above, with fewer exceptions (no object or image recognition)Passkeys, email links

Why 4.1.1 Parsing was removed. It asked for well-formed markup: no duplicate attributes, correctly nested tags. Browsers now repair broken HTML in the same, standard way, so most parsing errors no longer harm users, and testers were flagging errors nobody could notice. The real problems it caught, such as a duplicate id that breaks aria-labelledby, are still failures under 1.3.1 Info and Relationships and 4.1.2 Name, Role, Value. Keep validating your HTML; it still finds bugs.

Mapping criteria to HTML

Most criteria map to habits you already know.

CriterionLevelHTML technique
1.1.1 Non-text ContentAalt on <img>, alt="" for decoration
1.3.1 Info and RelationshipsAHeadings, lists, <th scope>, <label for>, <fieldset>
1.3.5 Identify Input PurposeAAautocomplete="name", "email", "postal-code"
2.1.1 KeyboardANative <button>, <a href>, form controls
2.4.1 Bypass BlocksALandmarks and a skip link
2.4.2 Page TitledAA unique <title>
2.4.4 Link Purpose (In Context)ALink text that makes sense, not "click here"
2.4.7 Focus VisibleAANever remove the outline without a replacement
3.1.1 Language of PageA<html lang="en">, and lang="hi" on Hindi phrases (3.1.2)
3.3.2 Labels or InstructionsAVisible <label> and hints with aria-describedby
4.1.2 Name, Role, ValueANative elements, or correct ARIA roles and states

When you review a component, ask "which criteria touch this?" A search box touches 1.3.1, 2.1.1, 2.4.7, 3.3.2 and 4.1.2.

Step 1: fix focus hidden under a sticky bar

Sticky cookie banners and chat bars are the most common way to fail 2.4.11. When a keyboard user tabs to a link at the bottom of the screen, the browser scrolls just enough to bring it into view, which puts it right behind the bar.

Run this, click in the page, and press Tab repeatedly with the fix off. Focused links slide under the bar. Then tick the box and try again.

HTMLOpen in editor
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Focus not obscured</title>
  <style>
    body { margin: 0; font-family: system-ui, sans-serif; padding-bottom: 5rem; }
    html.fixed { scroll-padding-bottom: 5rem; }
    li { padding: 0.6rem; }
    a:focus-visible { outline: 3px solid #d84315; outline-offset: 2px; }
    .bar { position: fixed; inset-inline: 0; bottom: 0; block-size: 4rem;
           background: #263238; color: white; display: flex; align-items: center; padding-inline: 1rem; }
  </style>
</head>
<body>
  <h1>Kochi Book Fair: stalls</h1>
  <p><label><input type="checkbox" id="fix"> Apply the scroll-padding fix</label></p>
  <ul id="stalls"></ul>
  <div class="bar">We use cookies to remember your language.</div>
  <script>
    const list = document.querySelector("#stalls");
    for (let i = 1; i <= 30; i++) {
      const li = document.createElement("li");
      const a = document.createElement("a");
      a.href = "#stall-" + i;
      a.textContent = "Stall " + i;
      li.append(a);
      list.append(li);
    }
    document.querySelector("#fix").addEventListener("change", (event) => {
      document.documentElement.classList.toggle("fixed", event.target.checked);
    });
  </script>
</body>
</html>

scroll-padding-bottom on the root element tells the browser that the bottom 5rem of the viewport is covered, so focus scrolling stops above it. The padding-bottom on the body lets the last links scroll clear of the bar. A banner that the user can close also helps.

Step 2: redundant entry and accessible authentication

Kabir is ordering school books from Rohtak. The second step asks for a billing address. Making him type it again fails 3.3.7. The login step must also not depend on memorising and retyping, which 3.3.8 covers.

HTMLOpen in editor
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Checkout</title>
  <style>
    body { font-family: system-ui, sans-serif; padding: 1rem; max-width: 30rem; }
    label { display: block; margin-top: 0.6rem; }
    input[type="text"], input[type="password"], textarea { width: 100%; padding: 0.4rem; }
    button { min-block-size: 44px; margin-top: 0.6rem; }
  </style>
</head>
<body>
  <h1>Checkout, step 2 of 3</h1>
  <form>
    <fieldset>
      <legend>Delivery address (from step 1)</legend>
      <textarea id="delivery" autocomplete="shipping street-address" rows="2" readonly>12 Model Town, Rohtak 124001</textarea>
    </fieldset>
    <fieldset>
      <legend>Billing address</legend>
      <label><input type="checkbox" id="same"> Same as delivery address</label>
      <label for="billing">Billing address</label>
      <textarea id="billing" autocomplete="billing street-address" rows="2"></textarea>
    </fieldset>
    <fieldset>
      <legend>Sign in to save this order</legend>
      <label for="email">Email</label>
      <input type="text" id="email" autocomplete="username" inputmode="email">
      <label for="pw">Password</label>
      <input type="password" id="pw" autocomplete="current-password">
      <button type="button" id="show" aria-pressed="false">Show password</button>
    </fieldset>
  </form>
  <script>
    const billing = document.querySelector("#billing");
    document.querySelector("#same").addEventListener("change", (event) => {
      billing.value = event.target.checked ? document.querySelector("#delivery").value : "";
      billing.readOnly = event.target.checked;
    });
    const show = document.querySelector("#show");
    show.addEventListener("click", () => {
      const pw = document.querySelector("#pw");
      const visible = pw.type === "text";
      pw.type = visible ? "password" : "text";
      show.setAttribute("aria-pressed", String(!visible));
    });
  </script>
</body>
</html>

What makes this pass:

  1. The checkbox copies the delivery address, so nothing is typed twice (3.3.7).
  2. autocomplete="username" and "current-password" let password managers fill the login. Nothing blocks paste (3.3.8).
  3. The Show password button lets people check what they typed. aria-pressed tells screen readers its state.

Things that would fail 3.3.8: blocking paste with onpaste="return false", splitting a password across separate boxes that stop autofill, or a puzzle CAPTCHA with no other option. For one-time passwords sent by SMS, use autocomplete="one-time-code" so phones can offer the code.

Dragging and consistent help

For 2.5.7, every drag needs a single-pointer alternative. A sortable to-do list can keep drag and drop but add buttons:

HTML
<li>
  Pay electricity bill
  <button type="button" aria-label="Move up: Pay electricity bill">↑</button>
  <button type="button" aria-label="Move down: Pay electricity bill">↓</button>
</li>

A native <input type="range"> already passes, because a click on the track or the arrow keys change the value.

For 3.2.6, put "Help" or "Contact us" in the same place on every page. A shared footer template does this automatically, which is another reason to build pages from shared parts.

The Indian context

India has its own rules that build on WCAG. Treat this as background, not legal advice.

  • GIGW (Guidelines for Indian Government Websites and Apps) are published by the National Informatics Centre (NIC) under the Ministry of Electronics and Information Technology. GIGW 3.0, released in 2023, asks government websites and apps to conform to WCAG 2.1 level AA. Details are on guidelines.india.gov.in.
  • The Rights of Persons with Disabilities Act, 2016 requires accessibility, including for information and communication technology, and lets the government set accessibility standards for it.

Because WCAG 2.2 includes all of 2.1, building to WCAG 2.2 AA also covers a WCAG 2.1 AA requirement such as GIGW's.

Common mistakes

  • Treating WCAG as a checklist of tags. It describes outcomes; many techniques can pass one criterion.
  • Testing only the home page. Conformance covers full pages and complete processes.
  • Blocking paste in password fields. This fails 3.3.8 and annoys everyone.
  • Sticky bars that cover focus. Add scroll-padding or make them dismissible.
  • Dropping validation because 4.1.1 is gone. Duplicate ids still break labels and ARIA.

Interview questions

1. What are the four WCAG principles?

Perceivable, Operable, Understandable and Robust, often called POUR. Every success criterion belongs to one of them. For example, text alternatives are Perceivable and keyboard access is Operable.

2. What does WCAG AA conformance mean?

The page meets every level A and level AA success criterion. It applies to full pages and to every page in a process such as checkout. AA is the level most laws and policies ask for.

3. Name some success criteria added in WCAG 2.2.

Nine were added, including 2.4.11 Focus Not Obscured (Minimum), 2.5.7 Dragging Movements, 2.5.8 Target Size (Minimum), 3.3.7 Redundant Entry and 3.3.8 Accessible Authentication (Minimum). Success criterion 4.1.1 Parsing was removed as obsolete.

4. How do you meet Accessible Authentication (Minimum)?

Do not make login depend on remembering, transcribing or solving a puzzle without help. Allow paste, support password managers with autocomplete="username" and "current-password", offer a show-password option and provide alternatives such as passkeys or email links.

5. Why was 4.1.1 Parsing removed?

Browsers now handle malformed markup in a consistent, specified way, so most parsing errors no longer affect assistive technology. The issues that still matter, such as duplicate ids used by ARIA, are covered by 1.3.1 and 4.1.2.

Key points

  • WCAG is a W3C standard of testable success criteria; 2.2 (October 2023) is the current version.
  • POUR: Perceivable, Operable, Understandable, Robust.
  • AA means all A and AA criteria, on full pages and complete processes.
  • WCAG 2.2 added nine criteria and removed 4.1.1 Parsing.
  • Map criteria to HTML: alt, labels, headings, autocomplete, native controls, visible focus.
  • GIGW 3.0 asks Indian government sites for WCAG 2.1 AA; the RPwD Act 2016 requires accessible ICT.

Exercise

Isha's coaching institute in Jaipur has a login page with a sticky "Admissions open" bar at the bottom, a password field with onpaste="return false", and a "Help" link that sits in the header on some pages and the footer on others. Write the corrected HTML and CSS, and next to each fix note the WCAG 2.2 success criterion and level it addresses.

Show solution
HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Student login | Isha Classes, Jaipur</title>
  <style>
    /* 2.4.11 Focus Not Obscured (Minimum), AA */
    html { scroll-padding-bottom: 4rem; }
    body { padding-bottom: 4rem; }
    .admissions { position: fixed; bottom: 0; inset-inline: 0; block-size: 3rem; }
  </style>
</head>
<body>
  <header>
    <!-- 3.2.6 Consistent Help, A: same place on every page -->
    <a href="/help">Help</a>
  </header>
  <main>
    <h1>Student login</h1>
    <form>
      <label for="user">Email</label>
      <input id="user" type="email" autocomplete="username">
      <!-- 3.3.8 Accessible Authentication (Minimum), AA: paste allowed, manager-friendly -->
      <label for="pw">Password</label>
      <input id="pw" type="password" autocomplete="current-password">
      <button>Log in</button>
    </form>
  </main>
  <div class="admissions">Admissions open for 2027</div>
</body>
</html>

Removing onpaste and adding autocomplete lets password managers work. The scroll padding keeps focused fields above the sticky bar, and the Help link now lives in the shared header on every page.

Quick Quiz

1. Which level must a page meet to claim AA conformance?

2. Which success criterion was removed in WCAG 2.2?

3. A shop makes users retype their address for billing in the same checkout. Which criterion does this fail?

4. Which WCAG version does GIGW 3.0 ask Indian government websites to meet?

Learn HTML with a mentor

Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call