- Level
- A
- Since
- WCAG 2.0
- Entries
- 70 / 193
4.1.1 Parsing
The code of a page has to be well formed (tags closed, elements nested correctly, no attribute or id used twice) so that software reading it does not have to guess.
/ What it requires
This criterion comes from a time when screen readers parsed HTML themselves and tripped over broken markup. It asks four things of content written in a markup language: elements have complete start and end tags, elements are nested according to their specifications, no element carries the same attribute twice, and every id is unique, except where the specification allows otherwise. When markup was broken, each tool repaired it in its own way, and a label or a table could end up attached to the wrong thing.
Today the browser repairs markup by a fixed algorithm and hands assistive technology a finished tree, so W3C removed 4.1.1 from WCAG 2.2. For WCAG 2.0 and 2.1 it published a note saying the criterion should be considered always satisfied for content in HTML or XML. What still matters is the consequence: a duplicate id that makes a label or an aria-labelledby reference point at the wrong element is now reported under 1.3.1 or 4.1.2.
W3C removed this criterion in WCAG 2.2 as obsolete; it remains part of WCAG 2.0 and 2.1, where W3C says it should be treated as always satisfied for HTML and XML content.
/ How pages fail it
- The same id value appears on two or more elements of one page.
- A component such as a form or a dialog is included twice, and every id inside it is repeated.
- An element is opened and never closed, or two elements are closed in the wrong order.
- An element sits where the specification does not allow it, such as a div inside a p or a link inside a link.
- An element carries the same attribute twice, for instance two class attributes.
/ How to check it yourself
- Run the page through the free W3C Nu Html Checker, by address or by pasting the source.
- Filter the results for four kinds of message: duplicate ID, unclosed element, element not allowed as child, and duplicate attribute.
- In the browser console, list the id values that occur more than once in the rendered page. Content added by script never appears in the raw source.
- For each duplicate id, search the page for for, aria-labelledby, aria-describedby and aria-controls attributes that use the value. Those are the duplicates that change what a user hears.
/ How to fix it
- Give every id a value that is unique on the page, starting with the ones referenced by for, aria-labelledby, aria-describedby and aria-controls.
- Where a component is rendered more than once, build its ids from a key of the instance or a generated suffix, not from a fixed string.
- Close every element that needs an end tag and correct the order of end tags that overlap.
- Move block content out of p elements, and never place one a element or one button inside another.
- Delete repeated attributes, so that each element keeps a single class, id or style attribute.
/ What our scanner checks
Two checks look only at ids. The duplicate-id check reads the rendered page and reports an id used more than once in the same tree, counting the document and each shadow root separately. HTML_CodeSniffer F77 reports any id value repeated in the document. Neither examines end tags, nesting or repeated attributes, and neither tells whether a duplicate actually breaks a label or an ARIA reference.
/ Who fails it, in our own measurements
| Body | Sector | Instances | Score |
|---|---|---|---|
| Poznań | city · PL | 154 | 1 |
| Stuttgart | city · DE | 88 | 6 |
| Gdańsk | city · PL | 74 | 2 |
| Bundesrat | government · DE | 70 | 14 |
| Phoenix | city · US | 67 | 1 |
| Seattle | city · US | 66 | 12 |
| Amtrak | transport · US | 42 | 1 |
| Wrocław | city · PL | 40 | 2 |
| Baltimore | city · US | 32 | 7 |
| Radom | city · PL | 26 | 2 |
| State of Texas | government · US | 26 | 22 |
| Internal Revenue Service | government · US | 22 | 20 |
| Austin | city · US | 18 | 13 |
| Cook County | government · US | 18 | 11 |
| Centrum e-Zdrowia | health · PL | 14 | 60 |
| Politechnika Łódzka | education · PL | 12 | 5 |
| Szczecin | city · PL | 12 | 3 |
| Robert Koch-Institut | health · DE | 11 | 10 |
| Politechnika Śląska | education · PL | 10 | 2 |
| Rzeszów | city · PL | 10 | 8 |
| Bremen | city · DE | 9 | 5 |
| Freie Universität Berlin | education · DE | 8 | 7 |
| State of Washington | government · US | 7 | 8 |
| Bundesregierung | government · DE | 6 | 4 |
| Gorzów Wielkopolski | city · PL | 6 | 6 |
| Statistisches Bundesamt | government · DE | 6 | 9 |
| Uniwersytet Gdański | education · PL | 6 | 18 |
| Uniwersytet Wrocławski | education · PL | 6 | 13 |
| Uniwersytet Łódzki | education · PL | 6 | 9 |
| Department of Justice | government · US | 5 | 27 |
| New York City | city · US | 5 | 37 |
| Bundesministerium der Finanzen | government · DE | 4 | 13 |
| Hannover | city · DE | 4 | 10 |
| Krajowa Administracja Skarbowa | government · PL | 4 | 5 |
| Nashville | city · US | 4 | 14 |
| Nürnberg | city · DE | 4 | 5 |
| Politechnika Poznańska | education · PL | 4 | 4 |
| Szkoła Główna Handlowa | education · PL | 4 | 12 |
| Warszawski Uniwersytet Medyczny | education · PL | 4 | 13 |
| Berliner Verkehrsbetriebe | transport · DE | 3 | 21 |
| Bundesverfassungsgericht | government · DE | 3 | 18 |
| Senat RP | government · PL | 3 | 24 |
| Białystok | city · PL | 2 | 37 |
| Boston | city · US | 2 | 6 |
| Bundesministerium des Innern | government · DE | 2 | 10 |
| Bydgoszcz | city · PL | 2 | 7 |
| Centers for Disease Control | health · US | 2 | 8 |
| Department of Labor | government · US | 2 | 46 |
| Deutsche Bahn | transport · DE | 2 | 6 |
| Gdynia | city · PL | 2 | 7 |
| Hamburg | city · DE | 2 | 22 |
| Katowice | city · PL | 2 | 12 |
| Köln | city · DE | 2 | 16 |
| Lublin | city · PL | 2 | 17 |
| Opole | city · PL | 2 | 8 |
| Philadelphia | city · US | 2 | 8 |
| Polski Instytut Sztuki Filmowej | culture · PL | 2 | 7 |
| Portland | city · US | 2 | 87 |
| Prezydent RP | government · PL | 2 | 12 |
| State of Florida | government · US | 2 | 8 |
| Toruń | city · PL | 2 | 11 |
| Uniwersytet Jagielloński | education · PL | 2 | 1 |
| Uniwersytet Warszawski | education · PL | 2 | 3 |
| Uniwersytet im. Adama Mickiewicza | education · PL | 2 | 12 |
| Urząd Ochrony Danych Osobowych | government · PL | 2 | 6 |
| Düsseldorf | city · DE | 1 | 9 |
| Generalna Dyrekcja Dróg Krajowych i Autostrad | transport · PL | 1 | 34 |
| Instytut Pamięci Narodowej | government · PL | 1 | 43 |
| Pacjent.gov.pl | health · PL | 1 | 9 |
| Politechnika Warszawska | education · PL | 1 | 12 |
One page per body, measured by automated checks on a weekly schedule. Any body that has fixed something since the last sweep will show it at the next one, and every entity page carries a right of reply.
/ Questions about this criterion
Is 4.1.1 Parsing still required?
Not in WCAG 2.2, where it was removed as obsolete. It is still listed in WCAG 2.0 and 2.1, and in standards built on 2.1 such as EN 301 549 version 3.2.1. For those versions W3C has stated that the criterion should be considered always satisfied for content in HTML or XML, so a validation error alone is no longer a failure.
Why was Parsing removed from WCAG 2.2?
It was written to protect assistive technology that parsed HTML directly and could be thrown off by broken markup. Assistive technology now reads the accessibility tree that the browser builds, and browsers repair markup in a standard way. W3C concluded that the problems either no longer exist or are covered by other criteria, mainly 1.3.1 and 4.1.2.
Are duplicate ids still an accessibility problem?
They can be. When two elements share an id, a label with a for attribute, or an aria-labelledby or aria-describedby reference, resolves to the first of them. A field can then be announced with the name of another field. Under WCAG 2.2 that is reported as a failure of 1.3.1 or 4.1.2. A duplicate id that nothing refers to harms nobody.
