Level
A
Since
WCAG 2.0
Entries
70 / 193
/ WCAG criterion

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

  1. Run the page through the free W3C Nu Html Checker, by address or by pasting the source.
  2. Filter the results for four kinds of message: duplicate ID, unclosed element, element not allowed as child, and duplicate attribute.
  3. 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.
  4. 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

Measured bodies failing this criterion, most instances first
BodySectorInstancesScore
Poznańcity · PL1541
Stuttgartcity · DE886
Gdańskcity · PL742
Bundesratgovernment · DE7014
Phoenixcity · US671
Seattlecity · US6612
Amtraktransport · US421
Wrocławcity · PL402
Baltimorecity · US327
Radomcity · PL262
State of Texasgovernment · US2622
Internal Revenue Servicegovernment · US2220
Austincity · US1813
Cook Countygovernment · US1811
Centrum e-Zdrowiahealth · PL1460
Politechnika Łódzkaeducation · PL125
Szczecincity · PL123
Robert Koch-Instituthealth · DE1110
Politechnika Śląskaeducation · PL102
Rzeszówcity · PL108
Bremencity · DE95
Freie Universität Berlineducation · DE87
State of Washingtongovernment · US78
Bundesregierunggovernment · DE64
Gorzów Wielkopolskicity · PL66
Statistisches Bundesamtgovernment · DE69
Uniwersytet Gdańskieducation · PL618
Uniwersytet Wrocławskieducation · PL613
Uniwersytet Łódzkieducation · PL69
Department of Justicegovernment · US527
New York Citycity · US537
Bundesministerium der Finanzengovernment · DE413
Hannovercity · DE410
Krajowa Administracja Skarbowagovernment · PL45
Nashvillecity · US414
Nürnbergcity · DE45
Politechnika Poznańskaeducation · PL44
Szkoła Główna Handlowaeducation · PL412
Warszawski Uniwersytet Medycznyeducation · PL413
Berliner Verkehrsbetriebetransport · DE321
Bundesverfassungsgerichtgovernment · DE318
Senat RPgovernment · PL324
Białystokcity · PL237
Bostoncity · US26
Bundesministerium des Innerngovernment · DE210
Bydgoszczcity · PL27
Centers for Disease Controlhealth · US28
Department of Laborgovernment · US246
Deutsche Bahntransport · DE26
Gdyniacity · PL27
Hamburgcity · DE222
Katowicecity · PL212
Kölncity · DE216
Lublincity · PL217
Opolecity · PL28
Philadelphiacity · US28
Polski Instytut Sztuki Filmowejculture · PL27
Portlandcity · US287
Prezydent RPgovernment · PL212
State of Floridagovernment · US28
Toruńcity · PL211
Uniwersytet Jagiellońskieducation · PL21
Uniwersytet Warszawskieducation · PL23
Uniwersytet im. Adama Mickiewiczaeducation · PL212
Urząd Ochrony Danych Osobowychgovernment · PL26
Düsseldorfcity · DE19
Generalna Dyrekcja Dróg Krajowych i Autostradtransport · PL134
Instytut Pamięci Narodowejgovernment · PL143
Pacjent.gov.plhealth · PL19
Politechnika Warszawskaeducation · PL112

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.