Summary
Ensuring all identifiers are unique prevents problems navigating and accessing the content.
Techniques
-
Verify that all
id
attributes have unique values. [[WCAG-4.1.1]]
Examples
Explanation
If all the id
attributes in a document are not unique, the user agent will not understand
which one is being referred to. For example, if a user is trying to navigate to a specific section,
the user agent will not be able to determine which one to go to. It might take the user
to the first section with the identifier, or it might leave the user at the top of document.
Other than being unique, the only requirement for identifiers in (X)HTML5 is that they not contain spaces.
Identifiers do not have to be unique across documents, although it is good practice to ensure uniqueness of all identifiers.
EPUB
Although (X)HTML5 allows any character string as an identifier, XML and XHTML 1.1 rules are stricter rules (e.g., identifiers cannot start with a number or include colons). Invalid identifiers in these cases, such as in EPUB 2 publications, cause XML errors that may lead to errors being display instead of content.
Related Links
- MDN — id
- HTML — The
id
attribute