Skip to content

    Frontend System Design

    Accessibility Fundamentals and WCAG

    Learn what WCAG asks of a front end: the four principles, the A, AA and AAA levels, the criteria developers meet most, and how to test and ship them.

    By Published 19 min read

    • frontend-system-design
    • accessibility
    • wcag
    • contrast
    • conformance
    Share

    Flagship lessonbeginnerFrontend System Design

    Before this: Semantic HTML and Document Structure

    What you'll learn: By the end of this lesson you will be able to explain what WCAG is and which versions exist, name its four principles and three levels, state what conformance does and does not require, work through the success criteria that front-end code meets most often (text alternatives, contrast, keyboard, focus, target size, name and role), compute a contrast ratio with the published formula, split accessibility checks between automated, manual and assistive-technology testing, and place those checks in a delivery pipeline.

    Think of a building code. A building is not "accessible" because one architect felt kind that day; it is accessible because there is a ramp where there are steps, a door wide enough for a wheelchair, signs that can be read from a distance and an alarm that is more than a sound. Those rules exist as a shared list, so builders, inspectors and owners can agree on what "done" means. The Web Content Accessibility Guidelines are that list for web pages: a shared, testable definition of what it takes for a page to be usable by people who see, hear, move and think in different ways.

    The running example is the product page and checkout of a grocery marketplace (the front end of the ShopStream marketplace used in this course): a search box, product cards with photographs and prices, an "Add to basket" control, a basket link with an item count, and a payment form. It is the kind of page where one missing label or one pale grey price decides whether a customer can buy at all.

    This lesson is the foundation for the accessibility lessons that follow in this module. It builds on Semantic HTML and Document Structure, which showed how native elements fill the accessibility tree.

    The core idea

    1. Accessibility is a set of testable requirements. WCAG states each requirement as a success criterion you can check, such as "text has a contrast ratio of at least 4.5:1", not a feeling.
    2. The requirements follow four questions. Can people perceive the content, operate the controls, understand what they are told, and can software of many kinds interpret the page reliably? WCAG calls these the four principles.
    3. Most of it is decided in the front end. Names, roles, keyboard handling, colour, sizes and focus are all produced by markup, CSS and JavaScript. Fixing them late is expensive; getting them from the start costs little.

    Who this is for

    W3C's accessibility fundamentals page describes the range: many people do not use a mouse and rely on the keyboard, captions and transcripts serve people who cannot hear audio or see video, good colour contrast helps people with colour blindness, and clear requirements help people with different types of cognitive disabilities. You do not design for a single "accessibility user"; you build to a standard that covers many ways of using a page, then check the result.

    What WCAG is

    WCAG stands for Web Content Accessibility Guidelines, and it is published by W3C. The W3C overview lists the versions: WCAG 2.0 (11 December 2008), WCAG 2.1 (5 June 2018) and WCAG 2.2 (5 October 2023), and describes WCAG 3 as only an early draft. WCAG 2.2 adds nine success criteria to 2.1, and its "new in 2.2" page says one older criterion, 4.1.1 Parsing, is obsolete and was removed. Otherwise the 2.0 and 2.1 criteria are essentially the same in 2.2.

    Because the 2.0 and 2.1 criteria carry over almost unchanged, work done for an earlier version mostly still counts. This lesson works from 2.2, the version current at the time of writing.

    The four principles

    The principles are the top level of the structure. In W3C's wording:

    Principle Wording from W3C A criterion that belongs to it
    Perceivable Information and user interface components must be presentable to users in ways they can perceive. 1.4.3 Contrast (Minimum)
    Operable User interface components and navigation must be operable. 2.1.1 Keyboard
    Understandable Information and the operation of user interface must be understandable. 3.3.7 Redundant Entry
    Robust Content must be robust enough that it can be interpreted reliably by a wide variety of user agents. 4.1.2 Name, Role, Value

    Each principle has guidelines, and each guideline has success criteria. The criteria are what you test; the principles are how to remember them. Practitioners often abbreviate the four as POUR (perceivable, operable, understandable, robust), which is a mnemonic, not a term the specification itself uses.

    The three levels

    Every success criterion is marked Level A, AA or AAA, with A the lowest. A page conforms at a level when it meets all the criteria of that level (and the lower ones). Examples from the criteria this lesson uses:

    Level Criteria in this lesson
    A 1.1.1 Non-text Content, 1.3.1 Info and Relationships, 1.4.1 Use of Color, 2.1.1 Keyboard, 2.5.3 Label in Name, 4.1.2 Name, Role, Value
    AA 1.4.3 Contrast (Minimum), 1.4.4 Resize Text, 1.4.10 Reflow, 2.4.7 Focus Visible, 2.5.8 Target Size (Minimum)

    W3C's conformance page lists five requirements for a conformance claim. In short: one level is met in full; it applies to full pages, so it cannot be achieved if part of a page is excluded; for a multi-step process, every page in the process conforms; only accessibility-supported ways of using technologies are relied upon; and technologies that are not accessibility-supported must not block users from the rest of the page. The same page says it is not recommended that Level AAA conformance be required as a general policy for entire sites, because it is not possible to satisfy all AAA criteria for some content. That does not make AAA criteria useless; many are worth adopting where they fit.

    Which level a product must meet is a business and legal decision. This lesson does not give legal advice; treat the level in your contract or policy as a requirement like any other.

    Figure 1. From principles to something you can test

    WCAG structure: principles, criteria and levels, then your checks4 principles to Criteria (decompose); Criteria to Levels (graded); Levels to Automated checks; Levels to Manual checks; Levels to Assistive tech4 principles: perceive, operate4 principlesperceive, operateCriteria: testableCriteriatestableLevels: A, AA, AAALevelsA, AA, AAAAutomated checks: partial coverageAutomatedcheckspartial coverageManual checks: keyboard, zoomManual checkskeyboard, zoomAssistive tech: screen readerAssistive techscreen readerdecomposegraded

    How to read this: the four principles are broken into success criteria, each graded A, AA or AAA. A criterion is checked in one or more ways: some by automated tools, some by a person with a keyboard and a zoom setting, some only with assistive technology. No single check covers all of them.

    The criteria front-end code meets most

    WCAG has far more criteria than fit in a lesson. The table lists the ones that most often come down to a markup, CSS or component decision, with what each asks (from the W3C "Understanding" pages) and where to look in code.

    Criterion Level What it asks Where to look
    1.1.1 Non-text Content A All non-text content has a text alternative; decoration is implemented so assistive technology can ignore it; a control or input has a name that describes its purpose alt on images, names on icon buttons
    1.3.1 Info and Relationships A Information, structure and relationships conveyed through presentation can be programmatically determined Headings, lists, labels tied to inputs
    1.4.1 Use of Color A Colour is not used as the only visual means of conveying information, indicating an action, prompting a response or distinguishing a visual element Error states, required fields, links in text
    1.4.3 Contrast (Minimum) AA At least 4.5:1 for text, 3:1 for large-scale text Design tokens, disabled and placeholder text
    1.4.4 Resize Text AA Text can be resized without assistive technology up to 200 percent without loss of content or functionality Fixed heights, clipped containers
    1.4.10 Reflow AA Content presents without two-dimensional scrolling at 320 CSS pixels wide (vertical scrolling content) Responsive layout, wide tables
    2.1.1 Keyboard A All functionality is operable through a keyboard interface Custom widgets, click-only handlers
    2.4.7 Focus Visible AA Any keyboard-operable interface has a mode where the focus indicator is visible outline: none resets
    2.5.3 Label in Name A The name contains the text presented visually aria-label that differs from visible text
    2.5.8 Target Size (Minimum) AA Pointer targets are at least 24 by 24 CSS pixels, with listed exceptions Icon buttons, dense lists
    4.1.2 Name, Role, Value A The name and role of every user interface component can be programmatically determined; user-settable states can be set programmatically Every custom control

    Four of these deserve a closer look.

    Contrast has two thresholds and no rounding. W3C's page says text and images of text need at least 4.5:1, large-scale text at least 3:1, where "large-scale" is at least 18 point or 14 point bold, and the page notes that 1 pt is 1.333 px, so those are roughly 24 and 18.5 pixels. It says computed values should not be rounded, so 4.499:1 fails. Text in an inactive user interface component, pure decoration, and text that is part of a logo have no contrast requirement.

    Keyboard operability is about function, not keys. All functionality must be operable through a keyboard interface without requiring specific timings for individual keystrokes. The only exception is a function that depends on the path of the movement, such as freehand drawing; dragging an item to a place and resizing a window are not exceptions.

    Target size has a spacing escape. WCAG 2.5.8 requires pointer targets of at least 24 by 24 CSS pixels, with exceptions: spacing (a 24-pixel circle centred on an undersized target does not intersect another target), an equivalent control, inline targets, browser-set size, and essential presentation. A small icon can pass if it has enough space around it.

    Name, Role, Value is the criterion behind custom controls. The W3C understanding page says standard HTML controls already meet it when used according to specification, and that it is primarily for authors who build or script their own components, who must take additional measures. Preferring native elements is therefore also an accessibility strategy; the next lesson, on semantic HTML, ARIA and accessible names, covers the additional measures.

    Figure 2. Choosing the first question to ask about a component

    flowchart TD accTitle: First questions to ask about a component against WCAG accDescr: A decision tree. Is there non-text content? If so, check the text alternative or decoration. Is it a control? If so, check that it has a name and role and works with the keyboard. Does it show text? If so, check contrast and resizing. Does it convey meaning by colour alone? If so, add a second cue. Does it use pointer input? If so, check target size. A{"What does the
    component do?"} A -->|"shows an image or icon"| B["1.1.1: text alternative
    or mark as decoration"] A -->|"is a control"| C["4.1.2 and 2.1.1:
    name, role, keyboard, focus"] A -->|"shows text"| D["1.4.3 and 1.4.4:
    contrast, resize"] A -->|"uses colour for meaning"| E["1.4.1:
    add text or an icon"] A -->|"is tapped or clicked"| F["2.5.8:
    size or spacing"]

    How to read this: one component can sit on several branches. A product card has an image, a link, text and a button, so it is checked against all of them. The point of the tree is to make the checks a habit during component review, not a late audit.

    Illustration 1: the minimal example, a contrast ratio

    The contrast criterion is the easiest to compute by hand, because W3C publishes the formula. Relative luminance is L = 0.2126 * R + 0.7152 * G + 0.0722 * B, where each 8-bit channel is divided by 255 and linearised (c / 12.92 when c <= 0.04045, otherwise ((c + 0.055) / 1.055) ^ 2.4). The contrast ratio is (L1 + 0.05) / (L2 + 0.05), with L1 the lighter colour. The same page notes the threshold in the linearisation was 0.03928 before May 2021 and was updated to 0.04045, which has no practical effect.

    Run in Node:

    function channel(value) {
      const s = value / 255;
      return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
    }
    function luminance(hex) {
      const n = parseInt(hex.slice(1), 16);
      const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map(channel);
      return 0.2126 * r + 0.7152 * g + 0.0722 * b;
    }
    function ratio(a, b) {
      const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x);
      return (light + 0.05) / (dark + 0.05);
    }
    const pairs = [
      ["#000000", "#ffffff", "black on white"],
      ["#767676", "#ffffff", "grey 767676 on white"],
      ["#777777", "#ffffff", "grey 777777 on white"],
      ["#ffffff", "#1a7f37", "white on green 1a7f37"],
      ["#ffffff", "#4caf50", "white on green 4caf50"],
    ];
    for (const [fg, bg, label] of pairs) {
      const r = ratio(fg, bg);
      console.log(`${label.padEnd(24)} ${r.toFixed(2)}:1  normal text (4.5): ${r >= 4.5 ? "pass" : "fail"}  large text (3): ${r >= 3 ? "pass" : "fail"}`);
    }
    console.log("raw 777777:", ratio("#777777", "#ffffff"));

    Output, from running it in Node 26.13.1:

    black on white           21.00:1  normal text (4.5): pass  large text (3): pass
    grey 767676 on white     4.54:1  normal text (4.5): pass  large text (3): pass
    grey 777777 on white     4.48:1  normal text (4.5): fail  large text (3): pass
    white on green 1a7f37    5.08:1  normal text (4.5): pass  large text (3): pass
    white on green 4caf50    2.78:1  normal text (4.5): fail  large text (3): fail
    raw 777777: 4.478089453577214

    Two greys that differ by one step in each channel sit on opposite sides of the threshold, and the unrounded value 4.478 is below 4.5 even though it prints as 4.48. The pale green that looks friendly as a "Pay now" button background fails even the large-text threshold with white text, while a darker green passes comfortably. The formula is the published one; the colours are illustrative choices, not a brand palette, and no design tool was compared.

    Testing: three kinds of check

    No tool can tell you a page is accessible, and W3C's own guidance on quick checks says so plainly: its checks cover just a few accessibility issues and are designed to be quick and easy, rather than definitive, and a page could seem to pass them and still have significant barriers. Its list is a useful starting set: page title, image text alternatives, headings, contrast, resize text, keyboard access and visual focus, forms with labels and errors, moving or flashing content, multimedia alternatives and basic structure.

    A workable split:

    • Automated checks run on every change and are good at presence and arithmetic: an img with no alt, a control with no name, a contrast ratio below the threshold. W3C's page gives the limit: automated tests can tell you if alt is missing, but whether the text is appropriate requires seeing the image and judging it in context.
    • Manual checks need no special software: tab through the page, look for the focus indicator, zoom to 200 percent, narrow the window to 320 CSS pixels, and ask whether the meaning survives without colour.
    • Assistive technology and people. Screen readers, speech input and switch devices expose problems the other two miss.

    Figure 3. Where each kind of check fits

    flowchart LR accTitle: Three kinds of accessibility check across the delivery pipeline accDescr: Left to right. Design reviews contrast and target size in the design system tokens. Developers get linting and unit tests with automated checks on every change. Pull request review adds a keyboard and zoom pass. Before release, a person using assistive technology tries the main journeys. After release, user reports feed back into the backlog. A["Design
    tokens, sizes"] --> B["Code
    lint, unit checks"] B --> C["Review
    keyboard, zoom pass"] C --> D["Before release
    assistive tech on key journeys"] D --> E["After release
    user reports to backlog"]

    How to read this: earlier is cheaper. A contrast decision in a design token costs one change; the same fault found as a bug costs a change in every place the colour was used. The later stages catch what the earlier ones cannot.

    Illustration 2: the realistic example, auditing the product page

    An audit of the ShopStream product page, done with an automated checker and then a keyboard pass, produces this list. Each defect is mapped to a criterion so the fix and the test are obvious. The page and its defects are an illustrative composite.

    Defect on the page Criterion Fix How it is caught later
    Product photo has no alt; the decorative divider has descriptive text 1.1.1 Describe the product; give the divider alt="" Automated check for missing alt; review of the text
    "Add to basket" is a div with a click handler 2.1.1, 4.1.2 Use a button Component test: reachable by role and name
    Price is #999 on white 1.4.3 Use a token that meets 4.5:1 Token-level contrast check
    Sale price is red with no other cue 1.4.1 Add the word "Sale" or an icon with a text name Design review; greyscale look
    Icon-only basket link has no name 1.1.1, 4.1.2 aria-label or visible text Automated check for a link with no name
    outline: none on all controls 2.4.7 Remove the reset or give a replacement indicator Keyboard pass

    Notice how many rows are fixed once in a shared component or a token rather than page by page. That is the argument for treating accessibility as part of the component system, covered in the design-system lessons of this module.

    Illustration 3: a failure, a green automated report on a bad page

    A team adds an automated accessibility check to the pipeline and it goes green. The product photographs each have alt="image". The tool sees an alt attribute and is satisfied. A screen reader user hears "image" repeated for every product and cannot tell basil from basil seed. The criterion (1.1.1) is not met in spirit: a presence check is not the same as a text alternative that serves the same purpose. MDN's guidance on alt makes the point directly: it should be a clear and concise replacement, and not describe the presence of the image itself.

    A green check means "none of the things this tool can detect were found", not "the page is accessible".

    Where accessibility lives in the architecture

    Most criteria in the table are produced in three layers; give each an owner.

    • Markup and components decide names, roles, structure and keyboard behaviour (1.1.1, 1.3.1, 2.1.1, 4.1.2). A component API can make the right thing the default: an icon button that requires a label prop cannot be shipped without a name.
    • Styles and tokens decide contrast, focus indicators, sizes, reflow and resizing (1.4.3, 1.4.4, 1.4.10, 2.4.7, 2.5.8). See Modern CSS Layout and Responsive Design for layout that reflows, and CSS Architecture and Scaling for how tokens are organised.
    • State and content decide what is announced and when: errors, loading and empty states (see Error, Loading and Empty States), validation messages (see Form State and Validation). Layout stability matters too: CLS and Layout Stability covers content that jumps under the pointer.

    Figure 4. The layers that produce accessibility

    Where accessibility is produced in a front endMarkup to Browser; Styles, tokens to Browser; State, content to Browser; Browser to Person (exposed)Markup: names, rolesMarkupnames, rolesStyles, tokens: contrast, focusStyles, tokenscontrast, focusState, content: errors, statusState, contenterrors, statusBrowser: accessibility treeBrowseraccessibilitytreePerson: any input, any outputPersonany input, anyoutputexposed

    How to read this: three layers of front-end code feed the browser, which exposes the result to the person through the screen, the keyboard, speech, braille or switch devices. A fault in any layer reaches the person; a fix is cheapest in the layer that caused it.

    Trade-offs

    Choice Gain Cost
    Target AA across the product A clear, widely used bar; few surprises Design and component work up front
    Target AAA for everything Highest bar Not achievable for some content; W3C advises against it as a blanket policy
    Automated checks in CI Fast, repeatable, catches regressions Partial coverage; false confidence
    Manual keyboard and zoom pass in review Finds real operability problems cheaply Takes reviewer time; needs a checklist
    Testing with assistive technology Finds what checklists miss Needs skill and devices
    Accessibility in the design system Fixes apply everywhere Harder to change a shared component

    Build it

    This lesson has no lab. Its claims come from the cited W3C and MDN pages, and the only code that was run is the contrast calculation above, shown unedited. The next lesson's lab, a simplified model of how an accessible name is chosen, covers name, role and value in running code. To explore this lesson yourself, tab through a page you work on, zoom to 200 percent, narrow the window to 320 CSS pixels, and compute its text contrast with the snippet. No screen reader, speech input tool or physical device was used.

    In practice: making checkout accessible

    NOTE

    This is a realistic scenario, not a case history. It is a composite built from common production patterns. It describes no specific company or product, and every number in it is an illustrative assumption.

    The situation

    The marketplace is preparing for a contract with a customer whose procurement team asks for evidence of WCAG 2.2 AA conformance for the shopping flow. Today there is no accessibility process: one engineer ran a browser extension once. Support has two open complaints, one from a keyboard-only user who cannot reach "Pay now" and one from a customer with low vision who cannot read the order summary.

    Starting architecture

    Figure 5. Accessibility as an afterthought

    Starting architecture: no owner, no checks, one-off auditsDesign to Components; Components to Release; Release to Customer (blocked)Design: no contrast ruleDesignno contrast ruleComponents: div buttonsComponentsdiv buttonsRelease: no a11y checkReleaseno a11y checkCustomer: keyboard, low visionCustomerkeyboard, lowvisionblocked

    How to read this: the warning boxes are stages with no accessibility rule. Faults pass through all three and arrive at the customer, who finds them first.

    Options considered

    Option What it fixes What it costs Risk
    One-off external audit and fix sprint A list of defects and a fix burst A fee and a sprint New defects reappear next quarter
    Overlay widget that claims to fix pages Fast to install A script on every page Whatever it changes, every criterion still has to be tested on the page itself
    Build the checks into the component system and pipeline Fixes persist; regressions are caught Slower first quarter Needs an owner and a checklist

    The decision

    Field Decision record
    Context A contract asks for WCAG 2.2 AA evidence; faults are in shared components and colours; checks are manual and rare.
    Decision Target 2.2 AA for the shopping flow. Fix the shared button, input and icon components first. Move colours into tokens with a contrast check. Add automated checks to CI, a keyboard and zoom pass to the review checklist, and a screen reader pass on the main journeys before each release. Record known gaps in a plain list rather than claim full conformance.
    Consequences, good Fixes land once and apply everywhere; the evidence is a process, not a report.
    Consequences, bad Components change shape (required label props); some pages need rework; the first quarter ships fewer features.
    Revisit when The contract level changes, WCAG 3 reaches a stable recommendation, or the checks start giving false confidence.

    Rollout and verification

    1. Inventory the flow: search, product, basket, address, payment, confirmation.
    2. Fix the shared parts first: button, link, labelled input, icon button with a required name, focus style, text colour tokens.
    3. Add the checks: a contrast check on tokens, automated checks for names and alt text, component tests that find each control by role and name.
    4. Run the manual passes: keyboard only through the whole flow; zoom to 200 percent; 320 CSS pixel width.
    5. Test with a screen reader on the main journeys, and publish the scope honestly: what was tested, with what, and what is open.

    The 2 a.m. failure

    A brand refresh changes the primary green and the "Pay now" button's white text drops under the 4.5:1 threshold, because the new token was approved from a mock-up and never checked. Nothing breaks in the test suite; the button simply becomes hard to read for some customers, and a support ticket arrives.

    First three checks: (1) compute the contrast of the new token pair with the formula; (2) look for every use of the token, not just the button; (3) check whether the pipeline has a contrast test on tokens at all. Mitigation: switch to the previous token or a darker variant that passes. Follow-up: a test that fails when any text and background token pair used together falls below its threshold.

    Architect's notes

    • Choose the target and write it down. "AA for the shopping flow" can be planned and tested; "accessible" cannot.
    • Fix at the layer that causes it. A contrast problem is a token problem; a missing name is a component API problem.
    • Make the right thing the default. A component that cannot be rendered without a name beats a guideline that says to add one.
    • Never report "no violations found" as "accessible". State what was tested and how.
    • Keep a known-issues list. An honest list is better than a silent gap.

    Common mistakes

    • Relying only on an automated tool. Presence checks pass alt="image".
    • Treating accessibility as a late audit instead of a property of components and tokens.
    • Using colour alone for errors, sale prices or required fields.
    • Removing the focus outline with no replacement.
    • Using div and span for controls, then trying to patch names and keys on top.
    • Rounding a contrast ratio. 4.478 is not 4.5.
    • Assuming a tool fixes the page without testing the result against the criteria.

    Key takeaways

    • WCAG is a set of testable success criteria under four principles (perceivable, operable, understandable, robust), graded A, AA and AAA. 2.2 is current, and 2.2 removed the old Parsing criterion.
    • Conformance applies to full pages and complete processes, and relies on accessibility-supported technology. AAA is not recommended as a blanket requirement.
    • Contrast is a formula: 4.5:1 for normal text, 3:1 for large text, unrounded.
    • Keyboard operability, visible focus, adequate target size and a programmatic name and role are the criteria most often decided in front-end code.
    • Automated checks find presence and arithmetic; people find the rest.
    • Put the fix in the layer that causes the fault: tokens for colour, components for names and keys.

    Practice exercises

    Exercise 1: Starter (30 min). Use the Node snippet to compute the contrast of your site's body text colour on its background, then of its link colour on the same background. Say which pass 4.5:1 and by how much.

    Exercise 2: Intermediate (2 hours). Tab through the checkout of an app you know with only the keyboard. List every control you could not reach or could not see focus on, and map each to a success criterion from the table.

    Exercise 3: Advanced (half day). Write a short test plan for a product card: three automated checks, three manual checks, and one thing only assistive technology will reveal. State what each cannot detect.

    In this course:

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments