Picto thématique

Rule n° 229 - Each HTML ID is only used once per page.

A website is not designed for a particular browser. It will be displayed in various consultation tools whose behaviours, in case of error in the code, will be very varied. Avoiding code errors therefore means preventing display problems. So, of course, absolute compliance with W3C standards is not always necessary. On the other hand, the multiple presence of the same identifier in a page can have a blocking impact, at least in terms of accessibility.

#Structure and code #Development #Accessibility

Goal

  • Prevent content reproduction errors and interaction errors via scripts.
  • Limit the risk of random interpretation of the Document Object Model (DOM) by different user agents.
  • Improve the accessibility of content for people with disabilities.

Implementation

The most drastic solution is to ensure the complete validity of the source code of the pages, using a validator such as http://validator.w3.org. However, this solution leads to taking account of all the source code validation errors which do not fall within the scope of this best practice. To keep to the scope of this best practice, take care to avoid any duplicate value of an id attribute in the same HTML page.

Find out more:

Control

Submit the page to the W3C HTML validator (validator.w3.org) or other code validation tool and verify that each id attribute value is unique within the page.

By Opquast - Read the license