Last updated:

Created by:

Success Criterion:

Description

This rule checks that labels describe the purpose of form field elements.

Accessibility Requirements

This conformance rule relates to:

Test Procedure

Applicability

This rule applies to any HTML label element or other element referenced by aria-labelledby that:

Note: The list of form field roles is derived by taking all the ARIA 1.1 roles that:

Note: This rule is a partial check for WCAG 2.1 success criterion 2.4.6, which applies to all labels. “Label” is used in its general sense and includes text or other components with a text alternative that is presented to a user to identify a component within Web content.

Expectation

Each target element describes the purpose of the associated form field element.

Note: Labels do not need to be lengthy. A word, or even a single character, may suffice.

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

Label that is coded with the label element and describes the purpose of the associated element.

Code Snippet:
 <label for="fname">First name:</label>
<input id="fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Passed example 2

Label that is coded with the p element and associated by the aria-labelledby attribute. The label describes the purpose of the associated element.

Code Snippet:
 <p id="label_fname">First name:</p>
<input aria-labelledby="label_fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Passed example 3

Implicit label that is coded with the label element and describes the purpose of the associated element.

Code Snippet:
 <label>First name:<input id="fname" type="text" name="fname"/></label>
 
Example Output: Open in a new tab/ window

Passed example 4

Label is visible, but not included in accessibility tree

Code Snippet:
 <p id="label_fname" aria-hidden="true">First name:</p>
<input aria-labelledby="label_fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Passed example 5

Label is included in accessibility tree, but not visible

Code Snippet:
 <p id="label_fname" style="position: absolute; top: -9999px; left: -9999px;">First name:</p>
<input aria-labelledby="label_fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Failed

Failed example 1

Label that is coded with the label element and does not describe the purpose of the associated element.

Code Snippet:
 <label for="fname">Menu</label>
<input id="fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Failed example 2

Label that is coded with the p element and associated by the aria-labelledby attribute. The label does not describe the purpose of the associated element.

Code Snippet:
 <p id="label_fname">Menu</p>
<input aria-labelledby="label_fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Failed example 3

Implicit label that is coded with the label element and does not describe the purpose of the associated element.

Code Snippet:
 <label>Menu<input id="fname" type="text" name="fname"/></label>
 
Example Output: Open in a new tab/ window

Passed example 4

Label is visible, but not included in accessibility tree, and does not describe the purpose of the associated element.

Code Snippet:
 <p id="label_fname" aria-hidden="true">Menu</p>
<input aria-labelledby="label_fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Passed example 5

Label is included in accessibility tree, but not visible, and does not describe the purpose of the associated element.

Code Snippet:
 <p id="label_fname" style="position: absolute; top: -9999px; left: -9999px;">Menu</p>
<input aria-labelledby="label_fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Inapplicable

Inapplicable example 1

Label that is neither visible to users, nor included in the accessibility tree.

Code Snippet:
 <label for="fname" style:"display:none;">First name:</label>
<input id="fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Inapplicable example 2

Programatically associated p element that is neither visible nor included in the accessibility tree.

Code Snippet:
 <p id="label_fname" style:"display:none;">First name:</p>
<input aria-labelledby="label_fname" type="text" name="fname"/>
 
Example Output: Open in a new tab/ window

Inapplicable example 3

The label element is associated with an HTML element that does not have a form field semantic role.

Code Snippet:
 <label for="fname" style:"display:none;">First name:</label>
<p id="fname"/>
 
Example Output: Open in a new tab/ window

Inapplicable example 4

No label element.

Code Snippet:
 <input id="fname" type="text" name="fname"/>
 
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

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.

Semantic Role

A semantic role is a semantic association that indicates an object’s type. This allows tools to present and support interaction with the object in a manner that is consistent with user expectations about other objects of that type.

Roles can be implicit through the element type or explicit through the role attribute.

The role attribute takes a list of tokens. The semantic role is the first valid role in this list. If none of the tokens are valid, the implicit role will be used instead.

Non-abstract roles defined in the following specifications are considered valid:

Other roles may be added as they become available. Not all roles will be supported in all assistive technologies. Testers are encouraged to adjust which roles are allowed according to the accessibility support base line. For the purposes of executing test cases in all rules, it should be assumed that all roles are supported by assistive technologies so that none of the roles fail due to lack of accessibility support.

Note: For HTML elements the implicit roles are documented in ARIA in HTML.

Test Aspects

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

  • CSS Styling

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!