ARIA in HTML - test case for invalid aria-hidden use
58 |
last updated 28 February 2021
59 |
The aria-hidden attribute is allowed on any element that allows for global aria-* attributes.
60 |
61 |
62 |
Tests:
63 |
64 |
65 |
66 |
Test 1
67 |
Authors MAY use the aria-hidden attribute on any HTML element that allows global aria-* attributes, with the following exceptions:
68 |
69 | aria-hidden is not allowed on:
70 |
71 |
72 |
base
73 |
col
74 |
colgroup
75 |
head
76 |
html
77 |
input type=hidden
78 |
link
79 |
map
80 |
meta
81 |
noscript
82 |
param
83 |
picture
84 |
script
85 |
slot
86 |
source
87 |
style
88 |
template
89 |
title
90 |
track
91 |
92 |
93 |
All elements represented above have been added to this document, in their proper locations so as to render in the browser. Each has an aria-hidden="false" so as to help ensure the test case will remain accessible.
94 |
95 |
96 |
97 |
98 |
table contains colgroup/col with aria-hidden
99 |
100 |
101 |
102 |
103 |
all other non-head or html elements follow with aria-hidden=false
ARIA in HTML - test case for aria-hidden on picture
63 |
last updated 16 December 2021
64 |
65 |
66 |
Tests:
67 |
68 |
69 |
70 |
Authors MAY use the aria-hidden attribute on the picture element.
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
Expected result:
80 | No errors or warnings for use of aria-hidden="true" on the picture element.
81 |
Additionally, since the image is hidden to assistive technologies per the parent picture having the aria-hidden=true
82 | attribute, checkers may consider not flagging the picture's child image for not having alternative text specified.
83 |
ARIA in HTML - test case for focusable elements which can use aria-hidden
69 |
last updated 28 February 2021
70 |
71 |
72 |
Tests:
73 |
74 |
75 |
76 |
Test 7
77 |
Authors MUST NOT use aria-hidden="true" on an element that can receive keyboard focus, or on an ancestor element to an element or elements which can receive keyboard focus.
78 |
79 |
This test case sets aria-hidden="true" on a div which contains focusable elements.
Expected result:
136 | No error produced because all elements as descendants of a aria-hidden="true" ancestor cannot receive keyboard focus from the tab key.
137 |
A warning may be desirable as these elements can still receive focus via "click", "tap", programmatically being focused (focus()), etc.
ARIA in HTML - test case for focusable elements which can use aria-hidden
69 |
last updated 28 February 2021
70 |
71 |
72 |
Tests:
73 |
74 |
75 |
76 |
Test 6
77 |
Authors MUST NOT use aria-hidden="true" on an element that can receive keyboard focus, or on an ancestor element to an element or elements which can receive keyboard focus.
78 |
79 |
This test case sets aria-hidden="true" on a div which contains focusable elements.
ARIA in HTML - test case for focusable elements which can use aria-hidden
69 |
last updated 28 February 2021
70 |
71 |
72 |
Tests:
73 |
74 |
75 |
76 |
Test 5
77 |
Authors MUST NOT use aria-hidden="true" on an element that can receive keyboard focus, or on an ancestor element to an element or elements which can receive keyboard focus.
78 |
79 |
This test case sets aria-hidden="true" on HTML elements which can normally receive focus or are necessary to make interactive elements. All elements have been provided tabindex="-1", removing them from standard keyboard focus via tab key.
ARIA in HTML - test case for focusable elements which can use aria-hidden
69 |
last updated 28 February 2021
70 |
71 |
72 |
Tests:
73 |
74 |
75 |
76 |
Test 4
77 |
Authors MUST NOT use aria-hidden="true" on an element that can receive keyboard focus, or on an ancestor element to an element or elements which can receive keyboard focus.
78 |
79 |
This test case sets aria-hidden="true" on HTML elements which can receive keyboard focus or are necessary to make interactive elements.
ARIA in HTML - test cases for body, html and head elements
56 |
last updated 31 August 2021
57 |
58 |
59 |
Tests:
60 |
61 |
62 |
63 |
Test 1
64 |
65 | No role is allowed on the body, html or head elements.
66 | To manually verify, check this page with a conformance checker. The html element has a role=document, and the head and body elements have role=presentation.
67 |
68 |
To verify additional roles, use the text field below to enter valid roles and dynamically apply them to the body, html and head elements, and then re-run the conformance checkers.
69 |
70 |
71 | Warning: adding certain ARIA roles to the body and html elements may make this page inaccessible.
72 |
73 |
77 |
78 |
79 |
93 |
94 |
Expectation: conformance checkers will indicate that role=document is redundant on html element, and that a role with any other value is invalid on the html element.
95 |
Conformance checkers will indicate that any role is invalid on the body and head elements.
ARIA in HTML - test case for role=combobox on button
48 |
last updated 15 January 2022
49 |
50 |
51 |
Tests:
52 |
Authors MAY use role=combobox on a button element, so long as other required attributes of the combobox role are also specified.
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
Expected result:
62 | This test fails because the button element has a role=combobox, but no other required attributes (aria-controls and aria-expanded).
63 |
64 |
65 |
66 |
67 |
68 |
69 |
option1
70 |
71 |
72 |
Expected result:
73 | This test passes. The button element has a role=combobox,
74 | and has the required aria-controls and aria-expanded attributes.
ARIA in HTML - test case for additional role allowances for button and input type=button elements
59 |
last updated 15 February 2023
60 |
61 |
62 |
Tests:
63 |
64 |
65 | Authors MAY use role=gridcell, slider or treeitem on a button element.
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
Expected result:
77 | These test cases would pass checks for an allowed role, but other failures would be expected as the elements are not contained or owned by their expected accessibility parents (gridcell or treeitem), or lack other expected properties required by authors (slider).
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | Expected result:
98 | No errors or warnings would be expected for these test cases, as they meet all the necessary requirements for use of these roles (necessary nesting and required attributes).
99 |
100 |
101 |
102 |
103 |
104 | Authors MAY use role=gridcell, slider or treeitem on a input type=button element.
105 |
106 |
107 | Note that while these roles are allowed, web authors will generally have a much easier time building these components using another HTML
108 | element as their base (e.g., a button or even a div).
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
Expected result:
119 | These test cases would pass checks for an allowed role, but other failures would be expected as the elements are not contained or owned by their expected accessibility parents (gridcell or treeitem), or lack other expected properties required by authors (slider).
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 | Expected result:
140 | No errors or warnings would be expected for these test cases, as they meet all the necessary requirements for use of these roles (necessary nesting and required attributes).
141 |
51 | checked is allowed on input type=checkbox and input type=radio elements
52 |
53 |
54 |
55 |
Tests:
56 |
57 |
58 |
59 |
Test 1
60 |
Authors SHOULD NOT use the aria-checked attribute on any element where the checkedness of the element can be in opposition to the current value of the aria-checked attribute.
61 |
62 |
The following input type=checkbox has an aria-checked=true, which does not update to match the checked state of the native element.
63 |
64 |
65 |
66 |
67 |
68 |
69 |
Expected result:
70 | Warning that authors should not use aria-checked on the input.
71 |
72 |
73 |
74 |
Test 2
75 |
Authors SHOULD NOT use the aria-checked attribute on any element where the checkedness of the element can be in opposition to the current value of the aria-checked attribute.
76 |
77 |
The following input type=radio elements each have an aria-checked=true, which does not update to match the checked state of the native element.
78 |
79 |
80 |
87 |
88 |
89 |
Expected result:
90 | Warning that authors should not use aria-checked on the inputs.
ARIA in HTML - test case for deprecated role=directory
49 |
last updated 10 January 2022
50 |
51 |
52 |
Tests:
53 |
54 |
55 |
56 |
Test 1
57 |
Authors are NOT RECOMMENDED to use the role=directory, as it has been deprecated. The following div, ul, ol and menu elements have a role=directory.
58 |
Authors should not need to use role=listitem on li elements, however not all browsers will respect the li mapping to listitem if the
59 | parent list element has a role=directory specified.
60 |
61 |
62 |
an item in the directory
63 |
an item in the directory
64 |
65 |
66 |
67 |
an item in the directory, no explicit role
68 |
an item in the directory with role=listitem
69 |
70 |
71 |
72 |
an item in the directory, no explicit role
73 |
an item in the directory with role=listitem
74 |
75 |
76 |
80 |
81 |
82 |
Expected result:
83 | warn authors role=directory has been deprecated, and that they should use a native list element (ul,
84 | ol, menu) or role=list instead.
85 |
Note: while a directory maps to a list,
86 | if used on a ul, ol or menu, their child li elements do not remain
87 | mapped to listitem in Chromium browsers. Firefox and Webkit do still map the li
88 | elements to listitem. Essentially, if not using listitem on each child of a directory, then
89 | those lists will be broken in Chromium browsers.
58 | disabled is allowed on input, button, select, textarea, fieldset, option, optgroup and form associated custom elements
59 |
60 |
note: a form associated custom element is not part of this test case
61 |
62 |
63 |
Tests:
64 |
65 |
66 |
67 |
Test 1
68 |
Authors MAY use the aria-disabled attribute on any element that is allowed the disabled attribute in HTML, or any element with a WAI-ARIA role which allows the aria-disabled attribute.
69 |
70 |
The following elements have aria-disabled=true attributes.
ARIA in HTML - test cases for allowed roles on img elements with and without names
49 |
last updated 14 June 2023
50 |
51 | If an image is provided a name using the alt attribute, or other valid naming mechanisms, then authors may specified the allowed roles on the element (while also meeting other requirements for the use of those roles - which are out of scope for this test).
52 |
53 |
54 | If an image lacks an accessible name, then only the roles of img, none and presentation are allowed, though not recommended as these are unnecessary for authors to specify.
55 |
56 |
57 |
58 |
Tests:
59 |
60 |
61 |
62 |
Test 1
63 |
64 | The following tests are of image elements with accessible names provided by use of alt, aria-label, aria-labelledby and the title attribute.
65 |
66 |
67 |
68 |
69 |
with alt
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
with title
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
with aria-label
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
with aria-labelledby
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
Expected result:
151 | No failures for use of ARIA roles would be flagged for any of the above examples. Use of img on a named image element is NOT RECOMMENDED. Confornamce checkers may indicate this as a warning.
152 |
153 |
154 |
155 |
Test 2
156 |
157 | Authors MUST NOT use roles other than none/presentation on an image with an empty alt and no accessible name, and MUST NOT use roles other than none/presentation or img if the element lacks an alt and has no accessible name.
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
Expected result:
170 | The above 5 examples should not fail allowed role rules. Conformance checkers may produce warnings for use of redundant roles on each of these examples.
ARIA in HTML - test case for additional role allowances for button and input type=button elements
59 |
last updated 15 February 2023
60 |
61 |
62 |
Tests:
63 |
64 |
65 | Allowances for input type=reset, input type=image and type=submit
66 |
67 |
68 | Authors are allowed to use the roles
69 | button, checkbox, combobox, gridcell, link, menuitem, menuitemcheckbox, menuitemradio, option, radio, slider, switch, tab or treeitem on a input type=reset, input type=image or input type=submit element.
70 |
71 |
72 | All allowed roles on the button element are now allowed on these elements as well. While there are far better elements to use as a base for these roles, if an author has no other choice and they end up using these elements to make an otherwise accessible custom widget, there is no reason to preclude their use as other automated and manual checks can call out potential accessibility gaps.
73 |
Expected result:
127 | These test cases would pass checks for an allowed role, but other failures would be expected for the instances where the elements are not contained or owned by their expected accessibility parents, or where they lack other expected properties required by authors. Note: there is no need to use a role=button on one of these elements, so while it's use is not recommended due to unnecessary redundncy, it is also not likely to cause issues.
128 |
129 |
130 |
131 |
132 |
133 |
input type=reset
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
input type=submit
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
input type=image
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 | Expected result:
227 | No errors would be expected for these test cases, as they meet all the necessary requirements for use of these roles (necessary nesting and required attributes). Conformance checkers could provide a warning or guidance to use a different HTML element as a base for these roles, if they so choose.
228 |
51 | max is allowed on meter, progress and input type date, month, week, time, datetime-local, number, range.
52 |
53 |
54 |
55 |
Tests:
56 |
57 |
58 |
59 |
Test 1
60 |
61 | Authors SHOULD NOT use the aria-valuemax attribute on any element which allows the max attribute. Use the max attribute instead.
62 |
63 |
64 |
65 |
inputs
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
meter
74 | 6 blocks used (out of 8 total)
75 |
progress
76 |
77 |
78 |
79 |
Expected result:
80 | Flag error or warning to authors to use max attribute instead. Authors may not be able to replicate all the necessary functionality of the native max attribute.
81 |
82 |
83 |
84 |
Test 2
85 |
86 | Authors MUST NOT use the aria-valuemax on any element which also has a max attribute, even if the values of each attribute match.
87 |
88 |
89 |
90 |
inputs
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
meter
99 | 6 blocks used (out of 8 total)
100 |
progress
101 |
102 |
103 |
104 |
Expected result:
105 | Error and tell authors to use max attribute by itself. Authors may not be able to replicate all the necessary functionality of the native max attribute.
51 | min is allowed on meter, and input type date, month, week, time, datetime-local, number, range.
52 |
53 |
54 |
55 |
Tests:
56 |
57 |
58 |
59 |
Test 1
60 |
61 | Authors SHOULD NOT use the aria-valuemin attribute on any element which allows the min attribute. Use the min attribute instead.
62 |
63 |
64 |
65 |
inputs
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
meter
74 | 6 blocks used (out of 8 total)
75 |
76 |
77 |
Expected result:
78 | Flag error or warning to authors to use min attribute instead. Authors may not be able to replicate all the necessary functionality of the native min attribute.
79 |
80 |
81 |
82 |
Test 2
83 |
84 | Authors MUST NOT use the aria-valuemin on any element which also has a min attribute, even if the values of each attribute match.
85 |
86 |
87 |
88 |
inputs
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
meter
97 | 6 blocks used (out of 8 total)
98 |
99 |
100 |
Expected result:
101 | Error and tell authors to use min attribute by itself. Authors may not be able to replicate all the necessary functionality of the native min attribute.
The placeholder attribute is allowed on input type=email, number, password, search, tel, text, url.
50 |
51 |
52 |
53 |
Tests:
54 |
55 |
56 |
57 |
Test 1
58 |
Authors MAY use the aria-placeholder attribute on any element that is allowed the placeholder attribute in HTML, or any element with a WAI-ARIA role which allows the aria-placeholder attribute.
59 |
60 |
The following inputs have aria-placeholder="test" set.
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
Expected result:
74 | No warning or error.
75 |
76 |
77 |
78 |
79 |
Test 2
80 |
Authors MUST NOT use the aria-placeholder attribute on any element which also has a placeholder attribute.
81 |
82 |
The following inputs have placeholder="test" and aria-placeholder="invalid" set.
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
Expected result:
96 | Error for use of aria-placeholder when element has a placeholder attribute set.
ARIA in HTML - test cases for elements which prohibit naming
25 |
last updated 12 March 2022
26 |
27 |
28 |
Tests:
29 |
30 | Each of the following test cases is an instance of an HTML element which either has an aria-labelledby or a aria-label attribute, which are not allowed for these elements with their implicit ARIA roles which prohibit naming.
31 |
32 |
Note: the body element of this page has an aria-label and aria-labelledby specified for checking purposes, as that element too is not allowed to be named by authors.
The readonly attribute is allowed on input type=text, search, url, tel, email, password, date, month, week, time, datetime-local, number. It is NOT RECOMMENDED to use aria-readonly on these elements.
56 |
aria-readonly=false is not allowed on an element with contenteditable.
57 |
58 |
59 |
Tests:
60 |
61 |
62 |
63 |
Test 1
64 |
Authors SHOULD NOT use the aria-readonly="true" on any element which also has a readonly attribute.
65 |
66 |
The following inputs have readonly and aria-readonly=true set.
The required attribute is allowed on input, select and textarea.
56 |
57 |
58 |
Tests:
59 |
60 |
61 |
62 |
Test 1
63 |
Authors MAY use the aria-required attribute on any element that is allowed the required attribute in HTML, or any element with a WAI-ARIA role which allows the aria-required attribute.
64 |
65 |
The following testcase sets aria-required on each element which allows the required attribute in HTML. The required attribute is only allowed on inputs with type of checkbox, date, datetime-local, email, file, month, number, password, radio, search, tel, text, time, url, or week.
66 |
67 |
Authors can't use aria-expanded or aria-pressed
58 | attributes on a summary element if it serves as the summary for its parent details element.
59 |
60 |
61 |
An aria-expanded attribute is ignored by user agents
62 |
63 | test 1
64 | has aria-expanded=false attribute
65 |
66 |
67 |
68 |
69 |
An aria-pressed attribute is ignored by user agents
70 |
71 | test 2
72 | has aria-pressed=true attribute
73 |
74 |
75 |
76 |
Expected result:
77 | As these attributes presently have no negative impact on the user experience, it seems that at the very least,
78 | conformance checkers should produce a warning about their use, since these 'were' previously 'allowed' but likely
79 | served no practical value then either. However, a conformance checker may expose these attributes as an error as well, as other
80 | allowed attribute checks that already exist may expose similar errors. E.g., div aria-expanded=true is another example of
81 | an invalid attribute being used on a generic element.
82 |
83 |
84 |
85 |
Test 2
86 |
Authors MAY specify any role on a summary element, so long as that summary element is not the 'summay for its parent details'.
87 |
88 |
89 |
The summary elements beyond the first instance do not pass the algorithm to be a summary for its parent details,
90 | so they are exposed as generic elements.
91 |
92 | no allowed role on this summary
93 | this summary has a paragraph role, which is fine.
94 | this summary has a button role, which is also fine.
95 |
96 |
97 |
98 |
99 |
The following summary element is not a child of a details element, and thus is implicitly exposed as a generic.
100 | this summary has a paragraph role, which is fine.
101 |
102 |
Expected result:
103 | Conformance checkers need not throw an error for summary elements that are not the first
104 | instance of the element type within a details element,
105 | or are not a descendant element of a details element.
106 |
107 |
108 |
109 |
110 |
111 |
112 |
Test 3
113 |
Authors can use aria-disabled or aria-haspopup
114 | attributes on a summary element when it serves as the summary for its parent details element.
115 |
116 |
117 |
Using an aria-disabled attribute is allowed
118 |
119 | test 1
120 | has aria-disabled=true attribute
121 |
122 |
123 |
124 |
125 |
Using an aria-haspopup attribute is allowed
126 |
127 | test 2
128 | has aria-haspopup=true attribute
129 |
130 |
131 |
132 |
Expected result:
133 | The aria-disabled and aria-haspopup attributes both have good support and are valid to use on the summary element when it acts as the interactive trigger for the details/summary disclosure widget. Other checks may be necessary to ensure that developers are using these attributes correctly, but that is beyond the scope of what ARIA in HTML covers.