Last updated:

Created by:

Success Criterion:

Description

This rule checks that all id attribute values on a single page are unique.

Accessibility Requirements

This conformance rule relates to:

Test procedure

Applicability

Any id attribute specified on an HTML or SVG element.

Note: Elements that are neither included in the accessibility tree nor visible on the page are still considered for this rule.

Expectation

The value of the attribute is unique across all other id attributes specified on HTML or SVG elements that exist within the same document tree or shadow tree as the element on which the applicable id attribute is specified.

Assumptions

There are currently no assumptions.

Accessibility Support

There are no major accessibility support issues known for this rule.

Background

Test Cases

Passed

Passed example 1

Only one id within the document context

Code Snippet:
 <div id="my-div"> This is my first element</div>
 
Example Output: Open in a new tab/ window

Passed example 2

All ids are unique within the document context

Code Snippet:
 <div id="my-div1"> This is my first element</div>
<div id="my-div2"> This is my second element</div>
<svg id="my-div3"> This is my third element</svg>
 
Example Output: Open in a new tab/ window

Passed example 3

id in shadow DOM is for the same element as id in light DOM

Code Snippet:
 <div id="my-elm"></div>
<script>
  var myElm = document.getElementById('my-elm');
  var shadow = myElm.attachShadow({ mode: 'open' });
  shadow.innerHTML = '<b id="my-elm" ><slot></slot></b>';
</script>
 
Example Output: Open in a new tab/ window

Failed

Failed example 1

Several elements have identical id

Code Snippet:
 <div id="my-div"> This is my first element</div>
<div id="my-div"> This is my second element</div>
 
Example Output: Open in a new tab/ window

Failed example 2

Elements of different types have identical id

Code Snippet:
 <div  id="my-div"> This is my first element</div>
<svg  id="my-div"> This is my second element</svg>
 
Example Output: Open in a new tab/ window

Failed example 3

Having display: none on an element still makes it applicable to this rule

Code Snippet:
 <div id="my-div" style="display:none"> This is my first element</div>
<svg id="my-div"> This is my second element</svg>
 
Example Output: Open in a new tab/ window

Inapplicable

Inapplicable example 1

No id on element

Code Snippet:
 <div>This is my first element</div>
 
Example Output: Open in a new tab/ window

Inapplicable example 2

XML id not applicable to this rule

Code Snippet:
 <div xml:id="my-div">This is my first element</div>
 
Example Output: Open in a new tab/ window

Glossary

Included in the accessibility tree

Elements included in the accessibility tree of platform specific accessibility APIs. Elements in the accessibility tree are exposed to assistive technologies, allowing users to interact with the elements in a way that meet the requirements of the individual user.

The general rules for when elements are included in the accessibility tree are defined in the core accessibility API mappings. For native markup languages, such as HTML and SVG, additional rules for when elements are [included in the accessibility tree][] can be found in the HTML accessibility API mappings and the SVG accessibility API mappings.

Note: Users of assistive technologies might still be able to interact with elements that are not included in the accessibility tree. An example of this is a focusable element with an aria-hidden attribute with a value of true. Such an element could still be interacted with using sequential keyboard navigation regardless of the assistive technologies used, even though the element would not be included in the accessibility tree.

Visible on the Page

Elements should be visible on the page, and also meet the requirements for color contrast and visibility when focused. For more details, check out:

Visible

Content perceivable through sight.

Content is considered visible if making it fully transparent would result in a difference in the pixels rendered for any part of the document that is currently within the viewport or can be brought into the viewport via scrolling.

Content is defined in WCAG.

Test Aspects

Test aspects are defined as part of the ACT Rules format 1.0.
  • DOM Tree

Contribute






GitHub

Contributing is open to anyone. We welcome any new issues or pull requests for changes. Auto WCAG Rules has conference calls every 4 weeks. If you are interested in becoming an active contributor or reviewer, we ask that you join the Auto WCAG Rules community group through the W3C Website. This requires setting up a W3C account, may require approval by the organization you work for if they are a W3C member.

Learn more about contributing to Auto WCAG Rules Join the Auto WCAG Rules community group now!