You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aria-practices.html
+120-1
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ <h4>Principle 2: ARIA Can Both Cloak and Enhance, Creating Both Power and Danger
106
106
<p>On the other hand, some uses of ARIA are more like suspenders or belts; they add meaning that provides essential support to the original content.</p>
It enables authors to describe nearly any user interface component in ways that assistive technologies can reliably interpret, thus making components accessible to assistive technology users.
@@ -6279,6 +6279,125 @@ <h3>Indicating sort order with <code>aria-sort</code></h3>
6279
6279
6280
6280
</section>
6281
6281
6282
+
<sectionid="aria-level">
6283
+
<h2>Describing Hierarchical Structure with <code>aria-level</code></h2>
6284
+
<p>When elements have a hierarchical relationship, such as headers of sections or data in tree structures, <code>aria-level</code> is used to communicate the hierarchy between elements to assistive technologies. The value of <code>aria-level</code> is numeric, with <code>1</code> indicating the top level of the structure. The number increases for each level of nesting.</p>
6285
+
<p>Do not use <code>aria-level</code> when the DOM structure already accurately represents the elements' hierarchical relationships.</p>
6286
+
<p>The <code>aria-level</code> attribute can be used on the following roles:</p>
6287
+
<ul>
6288
+
<li><code>heading</code></li>
6289
+
<li><code>listitem</code></li>
6290
+
<li><code>row</code></li>
6291
+
<li><code>tablist</code> (not recommended)</li>
6292
+
<li><code>grid</code> (not recommended)</li>
6293
+
</ul>
6294
+
<sectionid="aria-level_heading_role">
6295
+
<h3><code>heading</code> Role</h3>
6296
+
<p>Used together, the <code>aria-level</code> attribute and <code>heading</code> role will be treated the same by assistive technologies as the native HTML header elements: <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code> and <code>h6</code>. Do not use attribute <code>aria-level</code> and <code>heading</code> when a native HTML element can be used.</p>
6297
+
<p>This example uses the <code>heading</code> role and <code>aria-level</code> attribute to communicate levels of headings for a graph created with an SVG. The headings "Deciduous Trees" and "Evergreen Trees" are both subheadings to "Total Trees".</p>
<p>In rare scenarios, legacy code cannot be converted to using HTML header elements. In these cases, the <code>aria-level</code> attribute and the <code>heading</code> role can be added to the website's header elements to communicate to assitive technologies that those elements should be treated like a native HTML section heading element.</p>
6309
+
<p>For example, "Definition of a Room" is a subsection of "Housing Specification":</p>
<h2 id="room-definition">Definition of a Room</h2>
6320
+
...
6321
+
</section>
6322
+
</code></pre>
6323
+
</section>
6324
+
</section>
6325
+
6326
+
<sectionid="aria-level_listitem_role">
6327
+
<h3><code>listitem</code> role</h3>
6328
+
<p>The <code>aria-level</code> attribute can be used on elements with <code>listitem</code> role to represent list subitems when the structure of the DOM tree does not imply the intended level of nesting. For example, to quote a item in a nested to-do list, use the 'aria-level' attribute on the list items.</p>
6329
+
<pre><code><blockquote>
6330
+
<ul>
6331
+
<li aria-level="2">Wash Dishes</li>
6332
+
</ul>
6333
+
</blockquote>
6334
+
<p>I can do this item, but I can't do the other clean up items.</p>
6335
+
</code></pre>
6336
+
</section>
6337
+
6338
+
<sectionid="aria-level_treeitem_role">
6339
+
<h3><code>treeitem</code> role</h3>
6340
+
<p>The attribute <code>aria-level</code> can be used on elements with role <code>treeitem</code> to explicitly set the level of items within the <ahref="#TreeView">Tree View Design Pattern</a>.</p>
6341
+
<p>The computed <code>aria-level</code> of a <code>treeitem</code> within a tree is based on the number of 'group' role elements in the ancestor chain between the treeitem and the tree role, where the top level <code>treeitems</code> are <code>aria-level</code> 1. In the following example of a discussion board with nested replies, the top level post "What color should we paint the bike shed?" has an implicit <code>aria-level='1'</code>. The first reply has an implicit <code>aria-level='2'</code>, the response to that first reply has an implicit <code>aria-level='3'</code>.</p>
6342
+
<pre><code><ul role='tree'>
6343
+
<li role='treeitem'>
6344
+
What color should we paint the bike shed?
6345
+
<ul role='group'>
6346
+
<li role='treeitem''>
6347
+
Green.
6348
+
<ul role='group'>
6349
+
<li role='treeitem'>
6350
+
Green is boring, let's do purple.
6351
+
</li>
6352
+
</ul>
6353
+
</li>
6354
+
</ul>
6355
+
</li>
6356
+
</ul>
6357
+
</code></pre>
6358
+
<p>To override the <code>aria-level</code> calculated from the number of <code>group</code> role parents, set <code>aria-level</code> explicitly. Setting <code>aria-level</code> explictly might be necessary if only part of a tree is loaded and the implicity calculations cannot account for the missing part of the tree.</p>
I disagree with all 98 people who have replied before me, it should be rainbow colored.
6366
+
</li>
6367
+
</ul>
6368
+
</li>
6369
+
</ul>
6370
+
</code></pre>
6371
+
</section>
6372
+
6373
+
<sectionid="aria-level_row_role">
6374
+
<h3><code>row</code> Role</h3>
6375
+
<p>The <code>aria-level</code> attribute can be used on an element with <code>row</code> role to describe nesting of rows in a <code>treegrid</code>, as is explained in the <ahref="#treegrid">treegrid pattern</a>. In this example, the DOM tree does not represent the hierarchical relationship between rows. Each email is in a <code>tr</code> element, which are siblings in the DOM tree, therefore <code>aria-level</code> is necessary to communicate that the emails form a tree structure.</p>
6376
+
<pre><code><table role='treegrid'>
6377
+
<tr>
6378
+
<th>From:</th>
6379
+
<th>Subject:</th>
6380
+
</tr>
6381
+
<tr aria-level='1'>
6382
+
<td>Laura</td>
6383
+
<td>We should definitely cover the bike shed in rainbows.</td>
6384
+
</tr>
6385
+
<tr aria-level='2'>
6386
+
<td>Fred</td>
6387
+
<td>Re: We should definitely cover the bike shed in rainbows.</td>
6388
+
</tr>
6389
+
</table>
6390
+
</code></pre>
6391
+
<p>Do not use <code>aria-level</code> on rows that are in a <code>grid</code> or a <code>table</code> because only rows in a <code>treegrid</code> table are expected to have a hierarchical relationship.</p>
6392
+
</section>
6393
+
6394
+
<sectionid="aria-level_grid_role">
6395
+
<h3><code>grid</code> Role</h3>
6396
+
<p>The attribute <code>aria-level</code> can be used on elements with role <code>grid</code> to represent nested grids but it is not recommended.</p>
6397
+
</section>
6398
+
6399
+
</section>
6400
+
6282
6401
<sectionid="presentation_role">
6283
6402
<h2>Intentionally Hiding Semantics with the <code>presentation</code> Role</h2>
0 commit comments