The 0 attribute to expose the checkbox's state to assistive technology. Show
Note: The first rule of ARIA is if a native HTML element or attribute has the semantics and behavior you require, use it instead of re-purposing an element and adding ARIA. Instead use the native HTML checkbox of 1 (with an associated 2), which natively provides all the functionality required:
The native HTML checkbox ( 1) form control had two states ("checked" or "not checked"), with an state settable via JavaScript. Similarly, an element with role="checkbox" can expose three states through the 0 attribute: 7, 8, or 9.Since a checkbox is an interactive control, it must be focusable and keyboard accessible. If the role is applied to a non-focusable element, use the 0 attribute to change this. The expected keyboard shortcut for activating a checkbox is the Space key.The developer is required to change the value of the 0 attribute dynamically when the checkbox is activated.There are some types of user interface components that, when represented in a platform accessibility API, can only contain text. Accessibility APIs do not have a way of representing semantic elements contained in a 3 to all descendant elements of any checkbox element as it is a role that does not support semantic children.For example, consider the following
Because descendants of
From the assistive technology user's perspective, the heading does not exist since the previous code snippets are equivalent to the following in the accessibility tree:
0The value of 0 defines the state of a checkbox. This attribute has one of three possible values: 7The checkbox is checked. 8The checkbox is not checked. 9The checkbox is partially checked, or indeterminate. 2Used to make it focusable so the assistive technology user can tab to it and start reading right away. KeyFunctionSpaceActivates the checkbox Required event handlers 3Handle mouse clicks on both the checkbox and the associated label that will change the state of the checkbox by changing the value of the 0 attribute and the appearance of the checkbox so it appears checked or unchecked to the sighted user 5Handle the case where the user presses the Space key to change the state of the checkbox by changing the value of the 0 attribute and the appearance of the checkbox so it appears checked or unchecked to the sighted userThe following example creates an otherwise non-semantic checkbox element using CSS and JavaScript to handle the checked or unchecked status of the element.
When the
Assistive technology products should do the following:
People implementing checkboxes should do the following:
Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and may change. The first rule of ARIA is: if a native HTML element or attribute has the semantics and behavior you require, use it instead of re-purposing an element and adding an ARIA role, state or property to make it accessible. As such, it is recommended to use the native HTML checkbox using form control instead of recreating a checkbox's functionality with JavaScript and ARIA. |