Robust · 4.1 Compatible

Parsing WCAG 4.1.1 · Level A · removed in 2.2

In content that uses markup, elements must have complete start and end tags, be nested according to their specifications, have no duplicate attributes, and use unique IDs, except where the specifications allow otherwise. WCAG 2.2 removed this criterion as obsolete, and a 2023 note to WCAG 2.0 and 2.1 says it should be treated as always satisfied for HTML and XML content.

Level
A
In
WCAG 2.0, 2.1
Removed in
WCAG 2.2
Guideline
4.1 Compatible

Live demo

Listen to two hints that share an id

The same task, done two ways: switch between the version that passes and the one that fails, or put them side by side. Everything in the box is live, so try it with a keyboard, a pointer or a screen reader.

Compare what the screen reader preview says for the Security code field in each version.

Live example

Passes

Pay by card

The 16 digits on the front of your card.

The last 3 digits on the back of your card.

What happened

    Why it passes

    Each hint has its own id, so each field is read with its own hint. The Security code field tells you to use the 3 digits on the back of the card.

    Why it fails

    Both hints share one id, so the browser links both fields to the first hint. On the Security code field, a screen reader user hears the hint about the 16 digits on the front of the card and may type the wrong number.

    Examples

    Code that fails, and the fix

    Four examples, each one running: the usual ways this criterion fails, and code that passes. Listen to them, measure them, or copy the code.

    01What changes 2 lines

    Fails

    Two fields with the same id

    Live preview

    HTML
    <label for="email">Email address</label><input id="email" name="email" type="email" autocomplete="email"><label for="email">Confirm email address</label><input id="email" name="email-confirm" type="email">

    Both labels point at the first field, which gets both names, and the second field has no label at all. W3C's failure F77 covered duplicate ids.

    Passes

    A unique id for each field

    Live preview

    HTML
    <label for="email">Email address</label><input id="email" name="email" type="email" autocomplete="email"><label for="email-confirm">Confirm email address</label><input id="email-confirm" name="email-confirm" type="email">

    Each id is used once, so each label names its own field. Under WCAG 2.2 this is checked as part of 1.3.1 and 4.1.2.

    02What changes 1 line

    Fails

    End tags closed in the wrong order

    Live preview

    HTML
    <h2>Summer sale</h2><p>Sale ends <strong><em>Friday at midnight</strong></em>.</p>

    The em element opens inside strong but closes after it. Browsers repair this in a standard way, which is why 4.1.1 is now treated as always satisfied, but a validator still reports it.

    Passes

    Elements nested correctly

    Live preview

    HTML
    <h2>Summer sale</h2><p>Sale ends <strong><em>Friday at midnight</em></strong>.</p>

    Each element closes before its parent does, so the markup does not depend on the browser's repair rules.

    Why it matters

    Who it helps

    It helped people using assistive technologies that once read a page's markup directly and could fail or report the wrong thing when the markup was broken. Browsers now repair broken HTML in a standard way and assistive technologies use the browser's accessibility tree, so problems that still matter, such as a duplicate id that gives a field the wrong label, are reported under 1.3.1 or 4.1.2 instead.

    W3C: Understanding 4.1.1
    • Level A

      Level A is the minimum: failing it can shut some people out completely.

    • In WCAG versions

      In WCAG 2.0 and 2.1. WCAG 2.2 removed it as obsolete in October 2023.

      WCAG 1.0 checkpoints: 3.2

    • Where it is required

      Still counted where the law names WCAG 2.0 or 2.1: the United States, Canada, the European Union, France, Germany, Italy, Spain, the Netherlands, Ireland, Norway, Switzerland, India, Japan and Israel. W3C now says to treat it as always met for HTML.

    How to test

    Checking it

    The steps an audit against WCAG 2.0 or 2.1 still uses. For HTML, W3C now treats it as always met.

    1. Check the page with a markup validator, such as the W3C Nu Html Checker, and look for unclosed elements, wrongly nested elements, duplicate attributes and duplicate ids.
    2. Check that every id referenced by a label's for attribute, aria-labelledby, aria-describedby or aria-controls is used only once on the page.
    3. Under the 2023 W3C note, record 4.1.1 as satisfied for HTML and XML content, and report any problem that changes what assistive technology receives under 1.3.1 or 4.1.2.

    Common failures

    Where it breaks

    • Two elements share the same id, so a label's for attribute or an aria-describedby reference points at the wrong field.
    • An element that needs an end tag, such as a div, is never closed, so the content after it ends up inside it.
    • Elements overlap instead of nesting, such as a strong element that closes before the em element opened inside it.