diff --git a/aria-practices.html b/aria-practices.html index c25f7115d4..7734d38734 100644 --- a/aria-practices.html +++ b/aria-practices.html @@ -176,3643 +176,6 @@

Mobile and Touch Support

-
-

Landmark Regions

-

- ARIA landmark roles provide a powerful way to identify the organization and structure of a web page. - By classifying and labelling sections of a page, they enable structural information that is conveyed visually through layout to be represented programmatically. - Screen readers exploit landmark roles to provide keyboard navigation to important sections of a page. - Landmark regions can also be used as targets for "skip links" and by browser extensions to enhanced keyboard navigation. -

-

- This section explains how HTML sectioning elements and ARIA landmark roles - are used to make it easy for assistive technology users to understand the meaning of the layout of a page. -

-
-

HTML Sectioning Elements

-

- Several HTML sectioning elements automatically create ARIA landmark regions. - So, in order to provide assistive technology users with a logical view of a page, - it is important to understand the effects of using HTML sectioning elements. - [[HTML-ARIA]] contains more information on HTML element role mapping. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Default landmark roles for HTML sectioning elements
HTML ElementDefault Landmark Role
asidecomplementary
footercontentinfo when in context of the body element
headerbanner when in context of the body element
mainmain
navnavigation
sectionregion when it has an accessible name using aria-labelledby or aria-label
-
-
-

General Principles of Landmark Design

-

- Including all perceivable content on a page in one of its landmark regions - and giving each landmark region a semantically meaningful role - is one of the most effective ways of ensuring assistive technology users will not overlook information that is relevant to their needs. -

-

Step 1: Identify the logical structure

- - - -

Step 2: Assign landmark roles to each area

- - - -

Step 3: Label areas

- - -
- -
-

Landmark Roles

- -
-

Banner

- -

- A banner landmark identifies site-oriented content at the beginning of each page within a website. Site-oriented content typically includes things such as the logo or identity - of the site sponsor, and site-specific search tool. A banner usually appears at the top of the page and typically spans the full width. -

- -
    -
  • Each page may have one banner landmark.
  • - -
  • The banner landmark should be a top-level landmark.
  • - -
  • When a page contains nested document and/or application roles (e.g. typically through the use of iframe and frame elements), each document or application role may have - one banner landmark.
  • - -
  • If a page includes more than one banner landmark, each should have a unique label (see Step 3 above).
  • -
- -
-
HTML Techniques
-
    -
  • The HTML header element defines a banner landmark when its context is the body element.
  • - -
  • - The HTML header element is not considered a banner landmark when it is descendant of any of following elements (see HTML Accessibility Mappings [[HTML-AAM]]): -
      -
    • article
    • -
    • aside
    • -
    • main
    • -
    • nav
    • -
    • section
    • -
    -
  • -
- -
ARIA Techniques
- -

If the HTML header element technique is not being used, a role="banner" attribute should be used to define a banner landmark.

-
- -
-
Examples
- -

Banner Landmark Example

-
- -
- -
-

Complementary

- -

A complementary landmark is a supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful - when separated from the main content.

- -
    -
  • complementary landmarks should be top level landmarks (e.g. not contained within any other landmarks).
  • - -
  • If the complementary content is not related to the main content, a more general role should be assigned (e.g. region).
  • - -
  • If a page includes more than one complementary landmark, each should have a unique label (see Step 3 above).
  • -
- -
-
HTML Technique
- -

Use the HTML aside element to define a complementary landmark.

- -
ARIA Technique
- -

If the HTML aside element technique is not being used, use a role="complementary" attribute to define a complementary landmark.

-
- -
-
Examples
- -

Complementary Landmark Example

-
-
- -
-

Contentinfo

- -

A contentinfo landmark is a way to identify common information at the bottom of each page within a website, typically called the "footer" of the page, including information - such as copyrights and links to privacy and accessibility statements.

- -
    -
  • Each page may have one contentinfo landmark.
  • - -
  • The contentinfo landmark should be a top-level landmark.
  • - -
  • When a page contains nested document and/or application roles (e.g. typically through the use of iframe and frame elements), each document or application role may have - one contentinfo landmark.
  • - -
  • If a page includes more than one contentinfo landmark, each should have a unique label (see Step 3 above).
  • -
- -
- -
HTML Techniques
- -
    -
  • The HTML footer element defines a contentinfo landmark when its context is the body element.
  • - -
  • - The HTML footer element is not considered a contentinfo landmark when it is descendant of any of following elements (see HTML Accessibility Mappings [[HTML-AAM]]): -
      -
    • article
    • -
    • aside
    • -
    • main
    • -
    • nav
    • -
    • section
    • -
    -
  • -
- -
ARIA Technique
- -

If the HTML footer element technique is not being used, a role="contentinfo" attribute should be used to define a contentinfo landmark.

-
- -
-
Examples
-

Contentinfo Landmark Example

-
-
- -
-

Form

- -

A form landmark identifies a region that contains a collection of items and objects that, as a whole, combine to create a form when no other named landmark is appropriate (e.g. main - or search).

- -
    -
  • Use the search landmark instead of the form landmark when the form is used for search functionality.
  • - -
  • A form landmark should have a label to help users understand the purpose of the form.
  • - -
  • A label for the form landmark should be visible to all users (e.g. an h1-h6 element).
  • - -
  • If a page includes more than one form landmark, each should have a unique label (see Step 3 above).
  • - -
  • - Whenever possible, controls contained in a form landmark in an HTML document should use native host semantics: -
      -
    • button
    • - -
    • input
    • - -
    • select
    • - -
    • textarea
    • -
    -
  • -
- -
-
HTML Techniques
- -

The HTML form element defines a form landmark when it has an accessible name (e.g. aria-labelledby, aria-label or title).

- -
ARIA Technique
- -

Use the role="form" to identify a region of the page; do not use it to identify every form field.

-
- -
-
Examples
- -

Form Landmark Example

-
-
- -
-

Main

- -

A main landmark identifies the primary content of the page.

- -
    -
  • Each page should have one main landmark.
  • - -
  • The main landmark should be a top-level landmark.
  • - -
  • When a page contains nested document and/or application roles (e.g. typically through the use of iframe and frame elements), each document or application role may have - one main landmark.
  • - -
  • If a page includes more than one main landmark, each should have a unique label (see Step 3 above).
  • -
- -
-
HTML Technique
- -

Use the HTML main element to define a main landmark.

- -
ARIA Technique
- -

If the HTML main element technique is not being used, use a role="main" attribute to define a main landmark.

-
- -
-
Examples
- -

Main Landmark Example

-
-
- -
-

Navigation

- -

Navigation landmarks provide a way to identify groups (e.g. lists) of links that are intended to be used for website or page content navigation.

- -
    -
  • If a page includes more than one navigation landmark, each should have a unique label (see Step 3 above).
  • - -
  • If a navigation landmark has an identical set of links as another navigation landmark on the page, use the same label for each navigation landmark.
  • -
- -
-
HTML Technique
- -

Use the HTML nav element to define a navigation landmark.

- -
ARIA Technique
- -

If the HTML nav element technique is not being used, use a role="navigation" attribute to define a navigation landmark.

- -
- -
-
Examples
- -

Navigation Landmark Example

-
-
- -
-

Region

- -

A region landmark is a perceivable section of the page containing content that is sufficiently important for users to be able to navigate to the section.

- -
    -
  • A region landmark must have a label.
  • - -
  • If a page includes more than one region landmark, each should have a unique label (see Step 3 above).
  • - -
  • The region landmark can be used identify content that named landmarks do not appropriately describe.
  • -
- -
-
HTML Technique
- -

The HTML section element defines a region landmark when it has an accessible name (e.g. aria-labelledby, aria-label or title).

- -
ARIA Technique
- -

If the HTML section element technique is not being used, use a role="region" attribute to define a region landmark.

-
- -
-
Examples
- -

Region Landmark Example

-
-
- - -
-
- -
-

Providing Accessible Names and Descriptions

-

- Providing elements with accessible names, and where appropriate, accessible descriptions is one of the most important responsibilities authors have when developing accessible web experiences. - While doing so is straightforward for most elements, technical mistakes that can completely block users of assistive technologies are easy to make and unfortunately common. - To help authors effectively provide accessible names and descriptions, this section explains their purpose, when authors need to provide them, how browsers assemble them, and rules for coding and composing them. - It also guides authors in the use of the following naming and describing techniques and WAI-ARIA properties: -

- - -
-

What ARE Accessible Names and Descriptions?

-

- An accessible name is a short string, typically 1 to 3 words, that authors associate with an element to provide users of assistive technologies with a label for the element. - For example, an input field might have an accessible name of "User ID" or a button might be named "Submit". -

-

An accessible name serves two primary purposes for users of assistive technologies, such as screen readers:

-
    -
  1. Convey the purpose or intent of the element.
  2. -
  3. Distinguish the element from other elements on the page.
  4. -
-

- Both the WAI-ARIA specification and WCAG require all focusable, interactive elements to have an accessible name. - In addition dialogs and some structural containers, such as tables and regions, are required to have a name. - Many other elements can be named, but whether a name will enhance the accessible experience is determined by various characteristics of the surrounding context. - Finally, there are some elements where providing an accessible name is technically possible but not advisable. - The Accessible Name Guidance by Role section lists naming requirements and guidelines for every ARIA role. -

-

- An accessible description is also an author-provided string that is rendered by assistive technologies. - Authors supply a description when there is a need to associate additional information with an element, such as instructions or format requirements for an input field. -

-

- Assistive technologies present names differently from descriptions. - For instance, screen readers typically announce the name and role of an element first, e.g., a button named Mute Conversationcould be spoken as Mute Conversation button. - If an element has a state, it could be announced either before or after the name and role; after name and role is the typical default. - For example, a switch button named Mute Conversation in the off state could be announced as Mute Conversation switch button off. - Because descriptions are optional strings that are usually significantly longer than names, they are presented last, sometimes after a slight delay. - For example, Mute Conversation Switch button off, Silences alerts and notifications about activity in this conversation. - To reduce verbosity, some screen readers do not announce descriptions by default but instead inform users of their presence so that users can press a key that will announce the description. -

-
- -
-

How Are Name and Description Strings Derived?

-

- Because there are several elements and attributes for specifying text to include in an accessible name or description string, and because authors can combine them in a practically endless number of ways, browsers implement fairly complex algorithms for assembling the strings. -The sections on accessible name calculation and accessible description calculation explain the algorithms and how they implement precedence. -However, most authors do not need such detailed understanding of the algorithms since nearly all circumstances where a name or description is useful are supported by the coding patterns described in the naming techniques and describing techniques sections. -

-
- -
-

Cardinal Rules of Naming

- -
-

Rule 1: Heed Warnings and Test Thoroughly

-

- Several of the naming techniques below include notes that warn against specific coding patterns that are either prohibited by the ARIA specification or fall into gray space that is not yet fully specified. - Some of these prohibited or ambiguous patterns may appear logical and even yield desired names in some browsers. - However, it is unlikely they will provide consistent results across browsers, especially over time as work to improve the consistency of name calculation across browsers progresses. -

-

- In addition to heeding the warnings provided in the naming techniques, it is difficult to over emphasize the importance of testing to ensure that names browsers calculate match expectations. -

-
- -
-

Rule 2: Prefer Visible Text

-

- When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements. - When names are generated from text that exists only in markup and is never displayed visually, there is a greater likelihood that accessible names will not be updated when the user interface design or content are changed. -

-

- If an interactive element, such as an input field or button, does not have a visually persistent text label, consider adjusting the design to include one. - In addition to serving as a more robust source for an accessible name, visible text labels enhance accessibility for many people with disabilities who do not use assistive technologies that present invisible accessible names. - In most circumstances, visible text labels also make the user interface easier to understand for all users. -

-
- -
-

Rule 3: Prefer Native Techniques

-

- In HTML documents, whenever possible, rely on HTML naming techniques, such as the HTML label element for form elements and caption element for tables. - While less flexible, their simplicity and reliance on visible text help ensure robust accessible experiences. - Several of the naming techniques highlight specific accessibility advantages of using HTML features instead of ARIA attributes. -

-
- -
-

Rule 4: Avoid Browser Fallback

-

- When authors do not specify an accessible name using an element or attribute that is intended for naming, browsers attempt to help assistive technology users by resorting to fallback methods for generating a name. - For example, the HTML title and placeholder attributes are used as last resort sources of content for accessible names. - Because the purpose of these attributes is not naming, their content typically yields low quality accessible names that are not effective. -

-
- -
-

Rule 5: Compose Brief, Useful Names

-

- Similar to how visually crowded screens and ambiguous icons reduce usability, excessively long, insufficiently distinct, or unclear accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface. - In other words, for a web experience to be accessible, its accessible names must be effective. - The section on Composing Effective and User-friendly Accessible Names provides guidance for balancing brevity and clarity. -

-
-
- -
-

Naming Techniques

- -
-

Naming with Child Content

-

- Certain elements get their name from the content they contain. - For example, the following link is named "Home". -

- -
<a href="/">Home</a>
- -

- When assistive technologies render an element that gets its accessible name from its content, such as a link or button, the accessible name is the only content the user can perceive for that element. - This is in contrast to other elements, such as text fields or tables, where the accessible name is a label that is presented in addition to the value or content of the element. - For instance, the accessible name of a table can be derived from a caption element, and assistive technologies render both the caption and all other content contained inside the table. -

-

Elements having one of the following roles are, by default, named by a string calculated from their descendant content:

-
    -
  • button
  • -
  • cell
  • -
  • checkbox
  • -
  • columnheader
  • -
  • gridcell
  • -
  • heading
  • -
  • link
  • -
  • menuitem (content contained in a child menu element is excluded.)
  • -
  • menuitemcheckbox
  • -
  • menuitemradio
  • -
  • option
  • -
  • radio
  • -
  • row
  • -
  • rowheader
  • -
  • switch
  • -
  • tab
  • -
  • tooltip
  • -
  • treeitem (content included in a child group element is excluded.)
  • -
-

- When calculating a name from content for an element, user agents recursively walk through each of its descendant elements, calculate a name string for each descendant, and concatenate the resulting strings. - In two special cases, certain descendants are ignored: group descendants of treeitem elements and menu descendants of menuitem elements are omitted from the calculation. - For example, in the following tree, the name of the first tree item is Fruits; Apples, Bananas, and Oranges are omitted. -

-
<ul role="tree">
-  <li role="treeitem">Fruits
-    <ul role="group">
-      <li role="treeitem">Apples</li>
-      <li role="treeitem">Bananas</li>
-      <li role="treeitem">Oranges</li>
-    </ul>
-  </li>
-</ul>
-

- If an element with one of the above roles that supports naming from child content is named by using aria-label or aria-labelledby, content contained in the element and its descendants is hidden from assistive technology users unless the descendant content is referenced by aria-labelledby. - It is strongly recommended to avoid using either of these attributes to override content of one of the above elements except in rare circumstances where hiding content from assistive technology users is beneficial. - In addition, in situations where visible content is hidden from assistive technology users by use of one of these attributes, thorough testing with assistive technologies is particularly important. -

-
- -
-

Naming with a String Attribute Via aria-label

-

- The aria-label property enables authors to name an element with a string that is not visually rendered. - For example, the name of the following button is "Close". -

-
<button type="button" aria-label="Close">X</button>
-

- The aria-label property is useful when there is no visible text content that will serve as an appropriate accessible name. -

-

- The aria-label property affects assistive technology users in one of two different ways, depending on the role of the element to which it is applied. - When applied to an element with one of the roles that supports naming from child content, aria-label hides descendant content from assistive technology users and replaces it with the value of aria-label. - However, when applied to nearly any other type of element, assistive technologies will render both the value of aria-label and the content of the element. - For example, the name of the following navigation region is "Product". -

-
<nav aria-label="Product">
-  <!-- list of navigation links to product pages -->
-</nav>
-

- When encountering this navigation region, a screen reader user will hear the name and role of the element, e.g., "Product navigation region", and then be able to read through the links contained in the region. -

-
    -
  1. - If aria-label is applied to an element with one of the roles that supports naming from child content, content contained in the element and its descendants is hidden from assistive technology users. - It is strongly recommended to avoid using aria-label to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial. -
  2. -
  3. There are certain types of elements, such as paragraphs and list items, that should not be named with aria-label. They are identified in the table in the Accessible Name Guidance by Role section.
  4. -
  5. Because the value of aria-label is not rendered visually, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
  6. -
  7. When a user interface is translated into multiple languages, ensure that aria-label values are translated.
  8. -
-
- -
-

Naming with Referenced Content Via aria-labelledby

-

- The aria-labelledby property enables authors to reference other elements on the page to define an accessible name. - For example, the following switch is named by the text content of a previous sibling element. -

-
<span id="night-mode-label">Night mode</span>
-<span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
-

- Note that while using aria-labelledby is similar in this situation to using an HTML label element with the for attribute, one significant difference is that browsers do not automatically make clicking on the labeling element activate the labeled element; that is an author responsibility. - However, HTML label cannot be used to label a span element. - Fortunately, an HTML input with type="checkbox" allows the ARIA switch role, so when feasible, using the following approach creates a more robust solution. -

-
<label for="night-mode">Night mode</label>
-<input type="checkbox" role="switch" id="night-mode">
-

The aria-labelledby property is useful in a wide variety of situations because:

-
    -
  • It has the highest precedence when browsers calculate accessible names, i.e., it overrides names from child content and all other naming attributes, including aria-label.

  • -
  • It can concatenate content from multiple elements into a single name string.

  • -
  • -

    It incorporates content from elements regardless of their visibility, i.e., it even includes content from elements with the HTML hidden attribute, CSS display: none, or CSS visibility: hidden in the calculated name string.

    -
  • -
  • It incorporates the value of input elements, i.e., if it references a textbox, the value of the textbox is included in the calculated name string.

  • -
-

An example of referencing a hidden element with aria-labelledby could be a label for a night switch control:

-
<span id="night-mode-label" hidden>Night mode</span>
-<input type="checkbox" role="switch" aria-labelledby="night-mode-label">
- -

- In some cases, the most effective name for an element is its own content combined with the content of another element. - Because aria-labelledby has highest precedence in name calculation, in those situations, it is possible to use aria-labelledby to reference both the element itself and the other element. - In the following example, the "Read more..." link is named by the element itself and the article’s heading, resulting in a name for the link of "Read more... 7 ways you can help save the bees". -

-
<h2 id="bees-heading">7 ways you can help save the bees</h2>
-<p>Bees are disappearing rapidly. Here are seven things you can do to help.</p>
-<p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
-

- When multiple elements are referenced by aria-labelledby, text content from each referenced element is concatenated in the order specified in the aria-labelledby value. - If an element is referenced more than one time, only the first reference is processed. - When concatenating content from multiple elements, browsers trim leading and trailing white space and separate content from each element with a single space. -

-
<button id="download-button" aria-labelledby="download-button download-details">Download</button>
-<span id="download-details">PDF, 2.4 MB</span>
-

In the above example, the accessible name of the button will be "Download PDF, 2.4 MB", with a space between "Download" and "PDF", and not "DownloadPDF, 2.4 MB".

-
    -
  1. The aria-labelledby property cannot be chained, i.e., if an element with aria-labelledby references another element that also has aria-labelledby, the aria-labelledby attribute on the referenced element will be ignored.
  2. -
  3. If an element is referenced by aria-labelledby more than one time during a name calculation, the second and any subsequent references will be ignored.
  4. -
  5. There are certain types of elements, such as paragraphs and list items, that should not be named with aria-labelledby. They are identified in the table in the Accessible Name Guidance by Role section.
  6. -
  7. - If aria-labelledby is applied to an element with one of the roles that supports naming from child content, content contained in the element and its descendants is hidden from assistive technology users unless it is also referenced by aria-labelledby. - It is strongly recommended to avoid using this attribute to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial. -
  8. -
  9. Because calculating the name of an element with aria-labelledby can be complex and reference hidden content, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
  10. -
-
- -
-

Naming Form Controls with the Label Element

-

- The HTML label element enables authors to identify content that serves as a label and associate it with a form control. - When a label element is associated with a form control, browsers calculate an accessible name for the form control from the label content. -

-

- For example, text displayed adjacent to a checkbox may be visually associated with the checkbox, so it is understood as the checkbox label by users who can perceive that visual association. - However, unless the text is programmatically associated with the checkbox, assistive technology users will experience a checkbox without a label. - Wrapping the checkbox and the labeling text in a label element as follows gives the checkbox an accessible name. -

-
<label>
-  <input type="checkbox" name="subscribe">
-  subscribe to our newsletter
-</label>
-

- A form control can also be associated with a label by using the for attribute on the label element. - This allows the label and the form control to be siblings or have different parents in the DOM, but requires adding an id attribute to the form control, which can be error-prone. - When possible, use the above encapsulation technique for association instead of the following for attribute technique. -

-
<input type="checkbox" name="subscribe" id="subscribe_checkbox">
-<label for="subscribe_checkbox">subscribe to our newsletter</label>
-

- Using the label element is an effective technique for satisfying Rule 2: Prefer Visible Text. - It also satisfies Rule 3: Prefer Native Techniques. - Native HTML labels offer an important usability and accessibility advantage over ARIA labeling techniques: browsers automatically make clicking the label equivalent to clicking the form control. - This increases the hit area of the form control. -

-
- -
-

Naming Fieldsets with the Legend Element

-

- The HTML fieldset element can be used to group form controls, and the legend element can be used to give the group a name. - For example, a group of radio buttons can be grouped together in a fieldset, where the legend element labels the group for the radio buttons. -

-
<fieldset>
-  <legend>Select your starter class</legend>
-  <label><input type="radio" name="starter-class" value="green">Green</label>
-  <label><input type="radio" name="starter-class" value="red">Red</label>
-  <label><input type="radio" name="starter-class" value="blue">Blue</label>
-</fieldset>
-

- This grouping technique is particularly useful for presenting multiple choice questions. - It enables authors to associate a question with a group of answers. - If a question is not programmatically associated with its answer options, assistive technology users may access the answers without being aware of the question. -

-

- Similar benefits can be gained from grouping and naming other types of related form fields using fieldset and legend. -

-
<fieldset>
-  <legend>Shipping address</legend>
-  <p><label>Full name <input name="name" required></label></p>
-  <p><label>Address line 1 <input name="address-1" required></label></p>
-  <p><label>Address line 2 <input name="address-2"></label></p>
-  ...
-</fieldset>
-<fieldset>
-  <legend>Billing address</legend>
-  ...
-</fieldset>
-

Using the legend element to name a fieldset element satisfies Rule 2: Prefer Visible Text and Rule 3: Prefer Native Techniques.

-
- -
-

Naming Tables and Figures with Captions

-

- The accessible name for HTML table and figure elements can be derived from a child caption or figcaption element, respectively. - Tables and figures often have a caption to explain what they are about, how to read them, and sometimes giving them numbers used to refer to them in surrounding prose. - Captions can help all users better understand content, but are especially helpful to users of assistive technologies. -

-

- In HTML, the table element marks up a data table, and can be provided with a caption using the caption element. - If the table element does not have aria-label or aria-labelledby, then the caption will be used as the accessible name. - For example, the accessible name of the following table is Special opening hours. -

-
<table>
- <caption>Special opening hours</caption>
- <tr><td>30 May</td><td>Closed</td></tr>
- <tr><td>6 June</td><td>11:00-16:00</td></tr>
-</table>
-

The following example gives the table a number (Table 1) so it can be referenced.

-
<table>
- <caption>Table 1. Traditional dietary intake of Okinawans and other Japanese circa 1950</caption>
- <thead>
-  <tr>
-   <th></th>
-   <th>Okinawa, 1949</th>
-   <th>Japan, 1950</th>
-  </tr>
- <tbody>
-  <tr>
-   <th>Total calories</th>
-   <td>1785</td>
-   <td>2068</td>
-
-  [...]
-
-</table>
-

Note: Above table content is from Caloric restriction, the traditional Okinawan diet, and healthy aging: the diet of the world's longest-lived people and its potential impact on morbidity and life span.

-

- If a table is named using aria-label or aria-labelledby, then a caption element, if present, will become an accessible description. - For an example, see Describing Tables and Figures with Captions. -

-

- Similarly, an HTML figure element can be given a caption using the figcaption element. - The caption can appear before or after the figure, but it is more common for figures to have the caption after. -

-
<figure>
- <img alt="Painting of a person walking in a desert." src="Hole_JesusalDesierto.jpg">
- <figcaption>Jesus entering the desert as imagined by William Hole, 1908</figcaption>
-</figure>
-

- Like with table elements, if a figure is not named using aria-label or aria-labelledby, the content of the figcaption element will be used as the accessible name. - However unlike table elements, if the figcaption element is not used for the name, it does not become an accessible description unless it is referenced by aria-describedby. - Nevertheless, assistive technologies will render the content of a figcaption regardless of whether it is used as a name, description, or neither. -

-

Using the caption element to name a table element, or a figcaption element to name a figure element, satisfies Rule 2: Prefer Visible Text and Rule 3: Prefer Native Techniques.

-
- -
-

Fallback Names Derived from Titles and Placeholders

-

- When an accessible name is not provided using one of the primary techniques (e.g., the aria-label or aria-labelledby attributes), or native markup techniques (e.g., the HTML label element, or the alt attribute of the HTML img element), browsers calculate an accessible name from other attributes as a fallback mechanism. - Because the attributes used in fallback name calculation are not intended for naming, they typically yield low quality accessible names that are not effective. -So, As advised by Rule 4: Avoid Browser Fallback, prefer the explicit labeling techniques described above over fallback techniques described in this section. -

- -

- Any HTML element can have a title attribute specified. - The title attribute may be used as the element's fallback accessible name. - The title attribute is commonly presented visually as a tooltip when the user hovers over the element with a pointing device, which is not particularly discoverable, and is also not accessible to visual users without a pointing device. -

- -

For example, a fieldset element without a legend element child, but with a title attribute, gets its accessible name from the title attribute.

- -
<fieldset title="Select your starter class">
-  <label><input type="radio" name="starter-class" value="green">Green</label>
-  <label><input type="radio" name="starter-class" value="red">Red</label>
-  <label><input type="radio" name="starter-class" value="blue">Blue</label>
-</fieldset>
- -

- For the HTML input and textarea elements, the placeholder attribute is used as a fallback labeling mechanism if nothing else (including the title attribute) results in a label. - It is better to use a label element, since it does not disappear visually when the user focuses the form control. -

- -
<!-- Using a <label> is recommended -->
-<label>Search <input type=search name=q></label>
-
-<!-- A placeholder is used as fallback -->
-<input type=search name=q placeholder="Search">
-
-
- -
-

Composing Effective and User-friendly Accessible Names

-

- For assistive technology users, especially screen reader users, the quality of accessible names is one of the most significant contributors to usability. - Names that do not provide enough information reduce users' effectiveness while names that are too long reduce efficiency. - And, names that are difficult to understand reduce effectiveness, efficiency, and enjoyment. -

-

The following guidelines provide a starting point for crafting user friendly names.

- -
- -
-

Accessible Name Guidance by Role

-

- Certain elements always require a name, others may usually or sometimes require a name, and still others should never be named. - The table below lists all ARIA roles and provides the following information for each : -

-
-
Necessity of Naming
-
- Indicates how necessary it is for authors to add a naming attribute or element to supplement or override the content of an element with the specified role. - This column may include one of the following values: -
    -
  • - Required Only If Content Insufficient: An element with this role is named by its descendant content. - If aria-label or aria-labelledby is applied, content contained in the element and its descendants is hidden from assistive technology users unless it is also referenced by aria-labelledby. - Avoid hiding descendant content except in the rare circumstances where doing so benefits assistive technology users. -
  • -
  • Required: The ARIA specification requires authors to provide a name; a missing name causes accessibility validators to report an error.
  • -
  • Recommended: Providing a name is strongly recommended.
  • -
  • Discretionary: Naming is either optional or, in the circumstances described in the guidance column, is discouraged.
  • -
  • Do Not Name: Naming is strongly discouraged even if it is technically permitted; often assistive technologies do not render a name even if provided.
  • -
  • Prohibited: The ARIA specification does not permit the element to be named; If a name is specified, accessibility validators will report an error.
  • -
-
-
Guidance:
-
- Provides information to help determine if providing a name is beneficial, and if so, describes any recommended techniques. -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
roleNecessity of NamingGuidance
alertDiscretionary - Some screen readers announce the name of an alert before announcing the content of the alert. - Thus, aria-label provides a method for prefacing the visible content of an alert with text that is not displayed as part of the alert. - Using aria-label is functionally equivalent to providing off-screen text in the contents of the alert, except off-screen text would be announced by screen readers that do not support aria-label on alert elements. -
alertdialogRequiredUse aria-labelledby if a visible label is present, otherwise use aria-label.
applicationRequiredUse aria-labelledby if a visible label is present, otherwise use aria-label.
articleRecommended -
    -
  • Recommended to distinguish articles from one another; helps users when navigating among articles.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
-
bannerDiscretionary -
    -
  • Necessary in the uncommon circumstance where two banner landmark regions are present on the same page. It is otherwise optional.
  • -
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
  • See the Banner Landmark section.
  • -
-
blockquoteDiscretionary - If a visible label is present, associating it with the blockquote by using aria-labelledby could benefit some assistive technology users. -
buttonRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
-
captionProhibited
cellRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • Note that a name is not required; assistive technologies expect an empty cell in a table to be represented by an empty name.
  • -
  • Note that associated row or column headers do not name a cell; the name of a cell in a table is its content. Headers are complementary information.
  • -
-
checkboxRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • If based on HTML type="checkbox", use a label element.
  • -
  • Otherwise, reference visible content via aria-labelledby.
  • -
-
codeProhibited
columnheaderRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • If the columnheader role is implied from an HTML th, the HTML abbr attribute can be used to specify an abbreviated version of the name that is only announced when screen readers are reading an associated cell within the table, grid, or treegrid.
  • -
-
comboboxRequired -
    -
  • If the combobox role is applied to an HTML select or input element, can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
-
complementaryRecommended -
    -
  • Naming is necessary when two complementary landmark regions are present on the same page.
  • -
  • Naming is recommended even when one complementary region is present to help users understand the purpose of the region's content when navigating among landmark regions.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Complementary Landmark section.
  • -
-
contentinfoDiscretionary -
    -
  • Necessary in the uncommon circumstance where two contentinfo landmark regions are present on the same page. It is otherwise optional.
  • -
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
-
definitionRecommendedReference the term being defined with role="term", using aria-labelledby.
deletionProhibited
dialogRequiredUse aria-labelledby if a visible label is present, otherwise use aria-label.
directoryDiscretionary -
    -
  • Naming can help users understand the purpose of the directory.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
-
documentDiscretionary - Elements with the document role are contained within an element with the application role, which is required to have a name. - Typically, the name of the application element will provide sufficient context and identity for the document element. - Because the application element is used only to create unusual, custom widgets, careful assessment is necessary to determine whether or not adding an accessible name is beneficial. -
emphasisProhibited
feedRecommended -
    -
  • Helps screen reader users understand the context and purpose of the feed.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Feed Design Pattern.
  • -
-
figureRecommended -
    -
  • For HTML, use the figure and figcaption elements. The figcaption will serve as the accessible name for the figure. See the Naming Tables and Figures with Captions section.
  • -
  • When not using HTML, or when retrofitting legacy HTML, use the aria-labelledby on the figure, pointing to the figure's caption.
  • -
  • If there is no visible caption, aria-label can be used.
  • -
-
formRecommended -
    -
  • Helps screen reader users understand the context and purpose of the form landmark.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Form Landmark section.
  • -
-
genericProhibited
gridRequired -
    -
  • If the grid is applied to an HTML table element, then the accessible name can be derived from the table's caption element.
  • -
  • Otherwise, use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
-
gridcellRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • Note that a name is not required; assistive technologies expect an empty cell in a grid to be represented by an empty name.
  • -
  • Note that associated row or column headers do not name a gridcell; the name of a cell in a grid is its content. Headers are complementary information.
  • -
-
groupDiscretionary -
    -
  • When using the HTML fieldset element, the accessible name can be derived from the legend element.
  • -
  • When using the HTML details element, do not provide an accessible name for this element. The user interacts with the summary element, and that can derive its accessible name from its contents.
  • -
  • When using the HTML optgroup element, use the label attribute.
  • -
  • Otherwise, use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
-
headingRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
-
insertionProhibited
imgRequiredFor the HTML img element, use the alt attribute. For other elements with the img role, use aria-labelledby or aria-label.
linkRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
-
listDiscretionary -
    -
  • Potentially beneficial for users of screen readers that support both list names and navigation among lists on a page.
  • -
  • Potentially a source of distracting or undesirable screen reader verbosity, especially if nested within a named container, such as a navigation region.
  • -
  • Can be named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
-
listboxRequired -
    -
  • If the listbox role is applied to an HTML select element (with the multiple attribute or a size attribute having a value greater than 1), can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
  • See the Listbox Design Pattern.
  • -
-
listitemDo Not NameNaming is not supported by assistive technologies; it is necessary to include relevant content within the list item.
logDiscretionary - Some screen readers announce the name of a log element before announcing the content of the log element. - Thus, aria-label provides a method for prefacing the visible content of a log element with text that is not displayed as part of the log element. - Using aria-label is functionally equivalent to providing off-screen text in the contents of the log element, except off-screen text would be announced by screen readers that do not support aria-label on log elements. -
mainDiscretionary -
    -
  • Potentially helpful for orienting assistive technology users, especially in single-page applications where main content changes happen without generating a page load event.
  • -
  • Can be named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
  • See the Main Landmark section.
  • -
-
marqueeDiscretionaryUse aria-labelledby if a visible label is present, otherwise use aria-label.
mathRecommended -
    -
  • If the math element has only presentational children and the accessible name is intended to convey the mathematical expression, use aria-label to provide a string that represents the expression.
  • -
  • If the math element contains navigable content that conveys the mathematical expression and a visible label for the expression is present, use aria-labelledby.
  • -
  • Otherwise, use aaria-label to name the expression, e.g., aria-label="Pythagorean Theorem".
  • -
-
menuRecommended -
    -
  • Use aria-labelledby to refer to the menuitem or button that controls this element's display.
  • -
  • Otherwise, use aria-label.
  • -
  • See the Menu or Menu bar Design Pattern.
  • -
-
menubarRecommended -
    -
  • - Helps screen reader users understand the context and purpose of menuitem elements in a menubar. - Naming a menubar is comparable to naming a menu button. - The name of a button that opens a menu conveys the purpose of the menu it opens. - Since a menubar element is displayed persistently, a name on the menubar can serve that same purpose. -
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Menu or Menu bar Design Pattern.
  • -
-
menuitemRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • Note: content contained within a child menu is automatically excluded from the accessible name calculation.
  • -
  • See the Menu or Menu bar Design Pattern.
  • -
-
menuitemcheckboxRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • See the Menu or Menu bar Design Pattern.
  • -
-
menuitemradioRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • See the Menu or Menu bar Design Pattern.
  • -
-
meterRequired -
    -
  • If based on an HTML meter element, can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
-
navigationRecommended -
    -
  • Helps screen reader users understand the context and purpose of the navigation landmark.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Navigation Landmark section.
  • -
-
noneProhibitedAn element with role="none" is not part of the accessibility tree (except in error cases). Do not use aria-labelledby or aria-label.
noteDiscretionary -
    -
  • Naming is optional, but can help screen reader users understand the context and purpose of the note.
  • -
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
-
optionRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • See the Combobox Design Pattern.
  • -
-
paragraphProhibited
presentationProhibitedAn element with role="presentation" is not part of the accessibility tree (except in error cases). Do not use aria-labelledby or aria-label.
progressbarRequired -
    -
  • If the progressbar role is applied to an HTML progress element, can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
-
radioRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • If based on HTML type="checkbox", use a label element.
  • -
  • Otherwise, reference visible content via aria-labelledby.
  • -
-
radiogroupRequired -
    -
  • Recommended to help assistive technology users understand the purpose of the group of radio buttons.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Radio Group Design Pattern.
  • -
-
regionRequired -
    -
  • Helps screen reader users understand the context and purpose of the landmark.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Region Landmark section.
  • -
-
row - Required Only If Content Insufficient - AND descendant of a treegrid - AND the row is focusable - - When row elements are focusable in a treegrid, screen readers announce the entire contents of a row when navigating by row. - This is typically the most appropriate behavior. - However, in some circumstances, it could be beneficial to change the order in which cells are announced or exclude announcement of certain cells by using aria-labelledby to specify which cells to announce. -
rowgroupDo Not NameNaming is not supported by assistive technologies.
rowheaderRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • If the rowheader role is implied from an HTML th, the HTML abbr attribute can be used to specify an abbreviated version of the name that is only announced when screen readers are reading an associated cell within the table, grid, or treegrid.
  • -
-
scrollbarDiscretionary -
    -
  • Naming is optional, but can potentially help screen reader users understand the purpose of the scrollbar. The purpose is also conveyed using the aria-controls attribute, which is required for scrollbar.
  • -
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
-
searchRecommended -
    -
  • Helps screen reader users understand the context and purpose of the search landmark.
  • -
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
  • See the Search Landmark section.
  • -
-
searchboxRequired -
    -
  • If the searchbox role is applied to an HTML input element, can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
-
separatorDiscretionary -
    -
  • Recommended if there is more than one focusable separator element on the page.
  • -
  • Can help assistive technology users understand the purpose of the separator.
  • -
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • -
-
sliderRequired -
    -
  • If the slider role is applied to an HTML input element, can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
  • See the Slider Design Pattern and the Slider (Multi-Thumb) Design Pattern.
  • -
-
spinbuttonRequired -
    -
  • If the textbox role is applied to an HTML input element, can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
  • See the Spinbutton Design Pattern.
  • -
-
statusDiscretionary - Some screen readers announce the name of a status element before announcing the content of the status element. - Thus, aria-label provides a method for prefacing the visible content of a status element with text that is not displayed as part of the status element. - Using aria-label is functionally equivalent to providing off-screen text in the contents of the status element, except off-screen text would be announced by screen readers that do not support aria-label on status elements. -
strongProhibited
subscriptProhibited
superscriptProhibited
switchRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • If based on HTML type="checkbox", use a label element.
  • -
  • Otherwise, reference visible content via aria-labelledby.
  • -
-
tabRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
-
tableRequired -
    -
  • If using HTML table element, use the caption element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
  • See the Table Design Pattern.
  • -
-
tablistRecommended -
    -
  • Helps screen reader users understand the context and purpose of the tablist.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Carousel Design Pattern and Tabs Design Pattern.
  • -
-
tabpanelRequired - -
termDo Not NameSince a term is usually the name for the role="definition" element, it could be confusing if the term itself also has a name.
textboxRequired -
    -
  • If the textbox role is applied to an HTML input or textarea element, can be named with an HTML label element.
  • -
  • Otherwise use aria-labelledby if a visible label is present.
  • -
  • Use aria-label if a visible label is not present.
  • -
-
timeDo Not NameNaming is not supported by assistive technologies.
timerDiscretionary - Some screen readers announce the name of a timer element before announcing the content of the timer element. - Thus, aria-label provides a method for prefacing the visible content of a timer element with text that is not displayed as part of the timer element. - Using aria-label is functionally equivalent to providing off-screen text in the contents of the timer element, except off-screen text would be announced by screen readers that do not support aria-label on timer elements. -
toolbarRecommended -
    -
  • If there is more than one toolbar element on the page, naming is required.
  • -
  • Helps assistive technology users to understand the purpose of the toolbar, even when there is only one toolbar on the page.
  • -
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Toolbar Pattern.
  • -
-
tooltipRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
-
treeRequired - -
treegridRequired -
    -
  • If the treegrid is applied to an HTML table element, then the accessible name can be derived from the table's caption element.
  • -
  • Otherwise, use aria-labelledby if a visible label is present, otherwise use aria-label.
  • -
  • See the Treegrid Design Pattern.
  • -
-
treeitemRequired Only If Content Insufficient -
    -
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • -
  • Ideally named by visible, descendant content.
  • -
  • Note: content contained within a child group is automatically excluded from the accessible name calculation.
  • -
  • See the Tree View Design Pattern.
  • -
-
-
- -
-

Accessible name calculation

-

- User agents construct an accessible name string for an element by walking through a list of potential naming methods and using the first that generates a name. - The algorithm they follow is defined in the accessible name specification. - It is roughly like the following: -

-
    -
  1. The aria-labelledby property is used if present.

  2. -
  3. If the name is still empty, the aria-label property is used if present.

  4. -
  5. -

    If the name is still empty, then host-language-specific attributes or elements are used if present. For HTML, these are, depending on the element:

    -
    -
    input whose type attribute is in the Button, Submit Button, or Reset Button state
    -
    The value attribute.
    - -
    input whose type attribute is in the Image Button state
    -
    img
    -
    area
    -
    The alt attribute.
    - -
    fieldset
    -
    The first child legend element.
    - -
    Other form elements
    -
    The associated label element(s).
    - -
    figure
    -
    The first child figcaption element.
    - -
    table
    -
    The first child caption element.
    -
    -
  6. -
  7. If the name is still empty, then for elements with a role that supports naming from child content, the content of the element is used.

  8. -
  9. -

    Finally, if the name is still empty, then other fallback host-language-specific attributes or elements are used if present. For HTML, these are, depending on the element:

    -
    -
    input whose type attribute is in the Text, Password, Search, Telephone, or URL states
    -
    textarea
    -
    The title attribute. Otherwise, the placeholder attribute.
    - -
    input whose type attribute is in the Submit Button state
    -
    A localized string of the word "submit".
    - -
    input whose type attribute is in the Reset Button state
    -
    A localized string of the word "reset".
    - -
    input whose type attribute is in the Image Button state
    -
    The title attribute. Otherwise, a localized string of the phrase "Submit Query".
    - -
    summary
    -
    The word "Details".
    - -
    Other elements
    -
    The title attribute.
    -
    -
  10. -
-

- The final step is a fallback mechanism. Generally when labeling an element, use one of the non-fallback mechanisms. -

-

- When calculating a name from content, the user agent walks through all descendant nodes except in the cases of treeitem and menuitem as described below. - And, when following references in an aria-labelledby attribute, it similarly walks the tree of each referenced element. - Thus, the naming algorithm is recursive. - The following two sections explain non-recursive and recursive examples of how the algorithm works. -

-

- When calculating a name from content for the treeitem role, descendant content of child group elements are not included. - For example, in the following tree, the name of the first tree item is Fruits; Apples, Bananas, and Oranges are automatically omitted. -

-
<ul role="tree">
-  <li role="treeitem">Fruits
-    <ul role="group">
-      <li role="treeitem">Apples</li>
-      <li role="treeitem">Bananas</li>
-      <li role="treeitem">Oranges</li>
-    </ul>
-  </li>
-</ul>
-

- Similarly, when calculating a name from content for the menuitem role, descendant content of child menu elements are not included. - So, the name of the first parent menuitem in the following menu is Fruits. -

-
<ul role="menu">
-  <li role="menuitem">Fruits
-    <ul role="menu">
-      <li role="menuitem">Apples</li>
-      <li role="menuitem">Bananas</li>
-      <li role="menuitem">Oranges</li>
-    </ul>
-  </li>
-</ul>
- -
-

Examples of non-recursive accessible name calculation

-

Consider an input element that has no associated label element and only a name attribute and so does not have an accessible name (do not do this):

-
<input name="code">
-

If there is a placeholder attribute, then it serves as a naming fallback mechanism (avoid doing this):

- -
<input name="code"
-       placeholder="One-time code">
- -

If there is also a title attribute, then it is used as the accessible name instead of placeholder, but it is still a fallback (avoid doing this):

- -
<input name="code"
-       placeholder="123456"
-       title="One-time code">
- -

If there is also a label element (recommended), then that is used as the accessible name, and the title attribute is instead used as the accessible description:

- -
<label>One-time code
- <input name="code"
-        placeholder="123456"
-        title="Get your code from the app.">
-</label>
- -

If there is also an aria-label attribute (not recommended unless it adds clarity for assistive technology users), then that becomes the accessible name, overriding the label element:

- -
<label>Code
- <input name="code"
-        aria-label="One-time code"
-        placeholder="123456"
-        title="Get your code from the app.">
-</label>
- -

If there is also an aria-labelledby attribute, that wins over the other elements and attributes (the aria-label attribute ought to be removed if it is not used):

- -
<p>Please fill in your <span id="code-label">one-time code</span> to log in.</p>
-<p>
- <label>Code
-  <input name="code"
-         aria-labelledby="code-label"
-         aria-label="This is ignored"
-         placeholder="123456"
-         title="Get your code from the app.">
- </label>
-</p>
-
- -
-

Examples of recursive accessible name calculation

-

The accessible name calculation algorithm will be invoked recursively when necessary. An aria-labelledby reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.

- -

In this example, the label for the button is computed by recursing into each child node, resulting in Move to trash.

- -
<button>Move to <img src="bin.svg" alt="trash"></button>
- -

When following an aria-labelledby reference, the algorithm avoids following the same reference twice to avoid infinite loops.

- -

In this example, the label for the button is computed by first following the aria-labelledby reference to the parent element, and then computing the label for that element from the child nodes, first visiting the button element again but ignoring the aria-labelledby reference and instead using the aria-label, and then visiting the next child (the text node). The resulting label is Remove meeting: Daily status report.

- -
<div id="meeting-1">
-  <button aria-labelledby="meeting-1" aria-label="Remove meeting:">X</button>
-  Daily status report
-</div>
-
-
- -
-

Describing Techniques

-
-

Describing by referencing content with aria-describedby

-

- The aria-describedby property works similarly to the aria-labelledby property. - For example, a button could be described by a sibling paragraph. -

- -
<button aria-describedby="trash-desc">Move to trash</button>
-...
-<p id="trash-desc">Items in the trash will be permanently removed after 30 days.</p>
- -

Descriptions are reduced to text strings. For example, if the description contains an HTML img element, a text equivalent of the image is computed.

- -
<button aria-describedby="trash-desc">Move to <img src="bin.svg" alt="trash"></button>
-...
-<p id="trash-desc">Items in <img src="bin.svg" alt="the trash"> will be permanently removed after 30 days.</p>
- -

- As with aria-labelledby, it is possible to reference an element using aria-describedby even if that element is hidden. - For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. - The description could also be referenced from the text field directly with aria-describedby. - In the following example, the accessible description for the input element is Your username is the name that you use to log in to this service. -

- -
<label for="username">Username</label>
-<input id="username" name="username" aria-describedby="username-desc">
-<button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
-<p id="username-desc" hidden>
-  Your username is the name that you use to log in to this service.
-</p>
-
- -
-

Describing Tables and Figures with Captions

-

- In HTML, if the table is named using aria-label or aria-labelledby, a child caption element becomes an accessible description. - For example, a preceding heading might serve as an appropriate accessible name, and the caption element might contain a longer description. - In such a situation, aria-labelledby could be used on the table to set the accessible name to the heading content and the caption would become the accessible description. -

-
<h2 id="events-heading">Upcoming events</h2>
-<table aria-labelledby="events-heading">
- <caption>
-  Calendar of upcoming events, weeks 27 through 31, with each week starting with
-  Monday. The first column is the week number.
- </caption>
- <tr><th>Week</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th></tr>
- <tr><td>27</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
- <tr><td>28</td><td></td><td></td><td></td><td></td><td></td><td></td><td><a href="/events/9856">Crown Princess's birthday</a></td></tr>
- <tr><td>29</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
- <tr><td>30</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
- <tr><td>31</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
-</table>
-

The HTML figure element can get its accessible name from its figcaption element, but it will not be used as the accessible description, even if it was not used as the accessible name. If the figcaption element is appropriate as an accessible description, and the accessible name is set using aria-labelledby or aria-label, then the figcaption can be explicitly set as the accessible description using the aria-describedby attribute.

-
<h2 id="neutron">Neutron</h2>
-<figure aria-labelledby="neutron" aria-describedby="neutron-caption">
- <img src="neutron.svg" alt="Within the neutron are three quarks (blue 'u',
- red 'd', green 'd') that are interconnected.">
- <figcaption id="neutron-caption">
-  The quark content of the neutron. The color assignment of individual quarks is
-  arbitrary, but all three colors must be present. Forces between quarks are
-  mediated by gluons.
- </figcaption>
-</figure>
-
- -
-

Descriptions Derived from Titles

-

If an accessible description was not provided using the aria-describedby attribute or one of the primary host-language-specific attributes or elements (e.g., the caption element for table), then, for HTML, if the element has a title attribute, that is used as the accessible description.

-

A visible description together with aria-describedby is generally recommended. If a description that is not visible is desired, then the title attribute can be used, for any HTML element that can have an accessible description.

-

Note that the title attribute might not be accessible to some users, in particular sighted users not using a screen reader and not using a pointing device that supports hover (e.g., a mouse).

-

For example, an input element with input constrained using the pattern attribute can use the title attribute to describe what the expected input is.

-
<label> Part number:
- <input pattern="[0-9][A-Z]{3}" name="part"
-        title="A part number is a digit followed by three uppercase letters."/>
-</label>
-

The title attribute in this case can be shown to the user as a tooltip when the user hovers or focuses the control, but also as part of the error message when the user agent validates the form, if the input element's value doesn't match the pattern.

-

As another example, a link can use the title attribute to describe the link in more detail.

-
<a href="http://twitter.com/W3C"
-   title="Follow W3C on Twitter">
-   <img src="/2008/site/images/Twitter_bird_logo_2012.svg"
-        alt="Twitter" class="social-icon" height="40" />
-</a>
-
-
- -
-

Accessible description calculation

-

- Like the accessible name calculation, the accessible description calculation produces a text string. -

-

- The accessible description calculation algorithm is the same as the accessible name calculation algorithm except for a few branch points that depend on whether a name or description is being calculated. - In particular, when accumulating text for an accessible description, the algorithm uses aria-describedby instead of aria-labelledby. -

-

- User agents construct an accessible description string for an element by walking through a list of potential description methods and using the first that generates a description. - The algorithm they follow is defined in the accessible name specification. - It is roughly like the following: -

-
    -
  1. The aria-describedby property is used if present.

  2. -
  3. -

    If the description is still empty, then host-language-specific attributes or elements are used if present, if it wasn't already used as the accessible name. For HTML, these are, depending on the element:

    -
    -
    input whose type attribute is in the Button, Submit Button, or Reset Button state
    -
    The value attribute.
    - -
    summary
    -
    The element's subtree.
    - -
    table
    -
    The first child caption element.
    -
    -
  4. -
  5. -

    Finally, if the description is still empty, then other host-language-specific attributes or elements are used if present, if it wasn't already used for the accessible name. For HTML, this is the title attribute.

    -
  6. -
-
-
- -
-

Developing a Keyboard Interface

-

- Unlike native HTML form elements, browsers do not provide keyboard support for graphical user interface (GUI) components that are made accessible with ARIA; authors have to provide the keyboard support in their code. - This section describes the principles and methods for making the functionality of a web page that includes ARIA widgets, such as menus and grids, as well as interactive components, such as toolbars and dialogs, operable with a keyboard. - Along with the basics of focus management, this section offers guidance toward the objective of providing experiences to people who rely on a keyboard that are as efficient and enjoyable as the experiences available to others. -

-

This section covers:

-
    -
  1. Understanding fundamental principles of focus movement conventions used in ARIA design patterns.
  2. -
  3. Maintaining visible focus, predictable focus movement, and distinguishing between keyboard focus and the selected state.
  4. -
  5. Managing movement of keyboard focus between components, e.g., how the focus moves when the Tab and Shift+Tab keys are pressed.
  6. -
  7. Managing movement of keyboard focus inside components that contain multiple focusable elements, e.g., two different methods for programmatically exposing focus inside widgets like radio groups, menus, listboxes, trees, and grids.
  8. -
  9. Determining when to make disabled interactive elements focusable.
  10. -
  11. Assigning and revealing keyboard shortcuts, including guidance on how to avoid problematic conflicts with keyboard commands of assistive technologies, browsers, and operating systems.
  12. -
-
-

Fundamental Keyboard Navigation Conventions

- -

- ARIA roles, states, and properties model accessibility behaviors and features shared among GUI components of popular desktop GUIs, including Microsoft Windows, macOS, and GNOME. - Similarly, ARIA design patterns borrow user expectations and keyboard conventions from those platforms, consistently incorporating common conventions with the aim of facilitating easy learning and efficient operation of keyboard interfaces across the web. -

- -

- For a web page to be accessible, all interactive elements must be operable via the keyboard. - In addition, consistent application of the common GUI keyboard interface conventions described in the ARIA design patterns is important, especially for assistive technology users. - Consider, for example, a screen reader user operating a tree. - Just as familiar visual styling helps users discover how to expand a tree branch with a mouse, ARIA attributes give the tree the sound and feel of a tree in a desktop application. - So, screen reader users will commonly expect that pressing the right arrow key will expand a collapsed node. - Because the screen reader knows the element is a tree, it also has the ability to instruct a novice user how to operate it. - Similarly, voice recognition software can implement commands for expanding and collapsing branches because it recognizes the element as a tree and can execute appropriate keyboard commands. - All this is only possible if the tree implements the GUI keyboard conventions as described in the ARIA tree pattern. -

- -

- A primary keyboard navigation convention common across all platforms is that the tab and shift+tab keys move focus from one UI component to another while other keys, primarily the arrow keys, move focus inside of components that include multiple focusable elements. - The path that the focus follows when pressing the tab key is known as the tab sequence or tab ring. -

- -

- Common examples of UI components that contain multiple focusable elements are radio groups, tablists, menus, and grids. - A radio group, for example, contains multiple radio buttons, each of which is focusable. - However, only one of the radio buttons is included in the tab sequence. - After pressing the Tab key moves focus to a radio button in the group, pressing arrow keys moves focus among the radio buttons in the group, and pressing the Tab key moves focus out of the radio group to the next element in the tab sequence. -

- -

- The ARIA specification refers to a discrete UI component that contains multiple - focusable elements as a composite - widget. The process of controlling focus movement inside a composite is called - managing focus. Following are some ARIA design patterns with example implementations - that demonstrate focus management: -

- - -
- -
-

Discernible and Predictable Keyboard Focus

-

Work to complete this section is tracked by issue 217.

-

- When operating with a keyboard, two essentials of a good experience are the abilities to easily discern the location of the keyboard focus and to discover where focus landed after a navigation key has been pressed. - The following factors affect to what extent a web page affords users these capabilities. -

- -
    -
  1. Visibility of the focus indicator: Users need to be able to easily distinguish the keyboard focus indicator from other features of the visual design. Just as a mouse user may move the mouse to help find the mouse pointer, a keyboard user may press a navigation key to watch for movement. If visual changes in response to focus movement are subtle, many users will lose track of focus and be unable to operate. Authors are advised to rely on the default focus indicators provided by browsers. If overriding the default, consider: -
      -
    • something about ... Colors and gradients can disappear in high contrast modes.
    • -
    • Users need to be able to easily distinguish between focus and selection as described in , especially when a component that contains selected elements does not contain the focus.
    • -
    • ... other considerations to be added ...
    • -
    -
  2. - -
  3. Persistence of focus: It is essential that there is always a component within the user interface that is active (document.activeElement is not null or is not the body element) and that the active element has a visual focus indicator. Authors need to manage events that effect the currently active element so focus remains visible and moves logically. For example, if the user closes a dialog or performs a destructive operation like deleting an item from a list, the active element may be hidden or removed from the DOM. If such events are not managed to set focus on the button that triggered the dialog or on the list item following the deleted item, browsers move focus to the body element, effectively causing a loss of focus within the user interface.
  4. - -
  5. - Predictability of movement: Usability of a keyboard interface is heavily influenced by how readily users can guess where focus will land after a navigation key is pressed. - Some possible approaches to optimizing predictability include: - -
      -
    • - Move focus in a pattern that matches the reading order of the page's language. In left to right languages, for example, create a tab sequence that moves focus left to right and then top to bottom. -
    • - -
    • - Incorporate all elements of a section of the page in the tab sequence before moving focus to another section. For instance, in a page - with multiple columns that has content in a left side bar, center region, and right side bar, build a tab sequence that covers all elements in the left sidebar before focus moves to the first focusable element in the center column. -
    • - -
    • - When the distance between two consecutive elements in the tab sequence is significant, avoid movement that would be perceived as backward. - For example, on a page with a left to right language, a jump from the last element in the bottom right of the main content to the top element in a left-hand sidebar is likely to be less predictable and more difficult to follow, especially for users with a narrow field of view. -
    • - -
    • - Follow consistent patterns across a site. - The keyboard experience is more predictable when similar pages have similar focus movement patterns. -
    • - -
    • Do not set initial focus when the page loads except in cases where: -
        -
      • The page offers a single, primary function that nearly all users employ immediately after page load.
      • -
      • Any given user is likely to use the page often.
      • -
      -
    • -
    -
  6. -
-
- -
-

Focus VS Selection and the Perception of Dual Focus

- -

- Occasionally, it may appear as if two elements on the page have focus at the same time. - For example, in a multi-select list box, when an option is selected it may be greyed. - Yet, the focus indicator can still be moved to other options, which may also be selected. - Similarly, when a user activates a tab in a tablist, the selected state is set on the tab and its visual appearance changes. - However, the user can still navigate, moving the focus indicator elsewhere on the page while the tab retains its selected appearance and state. -

- -

- Focus and selection are quite different. - From the keyboard user's perspective, focus is a pointer, like a mouse pointer; it tracks the path of navigation. - There is only one point of focus at any time and all operations take place at the point of focus. - On the other hand, selection is an operation that can be performed in some widgets, such as list boxes, trees, and tablists. - If a widget supports only single selection, then only one item can be selected and very often the selected state will simply follow the focus when focus is moved inside of the widget. - That is, in some widgets, moving focus may also perform the select operation. - However, if the widget supports multiple selection, then more than one item can be in a selected state, and keys for moving focus do not perform selection. - Some multi-select widgets do support key commands that both move focus and change selection, but those keys are different from the normal navigation keys. - Finally, when focus leaves a widget that includes a selected element, the selected state persists. -

- -

- From the developer's perspective, the difference is simple -- the focused element is the active element (document.activeElement). - Selected elements are elements that have aria-selected="true". -

- -

With respect to focus and the selected state, the most important considerations for designers and developers are:

- - -
- -
-

Deciding When to Make Selection Automatically Follow Focus

-

in composite widgets where only one element may be selected, such as a tablist or single-select listbox, moving the focus may also cause the focused element to become the selected element. This is called having selection follow focus. Having selection follow focus is often beneficial to users, but in some circumstances, it is extremely detrimental to accessibility.

-

- For example, in a tablist, the selected state is used to indicate which panel is displayed. - So, when selection follows focus in a tablist, moving focus from one tab to another automatically changes which panel is displayed. - If the content of panels is present in the DOM, then displaying a new panel is nearly instantaneous. - A keyboard user who wishes to display the fourth of six tabs can do so with 3 quick presses of the right arrow. - And, a screen reader user who perceives the labels on tabs by navigating through them may efficiently read through the complete list without any latency. -

-

However, if displaying a new panel causes a network request and possibly a page refresh, the effect of having selection automatically focus can be devastating to the experience for keyboard and screen reader users. In this case, displaying the fourth tab or reading through the list becomes a tedious and time-consuming task as the user experiences significant latency with each movement of focus. Further, if displaying a new tab refreshes the page, then the user not only has to wait for the new page to load but also return focus to the tab list.

-

- When selection does not follow focus, the user changes which element is selected by pressing the Enter or Space key. -

-
- -
-

Keyboard Navigation Between Components (The Tab Sequence)

- -

As explained in section , all interactive UI components need to be reachable via the keyboard. This is best achieved by either including them in the tab sequence or by making them accessible from a component that is in the tab sequence, e.g., as part of a composite component. This section addresses building and managing the tab sequence, and subsequent sections cover making focusable elements that are contained within components keyboard accessible.

- -

- The [[HTML]] tabindex and [[SVG2]] tabindex attributes can be used to add and remove elements from the tab sequence. - The value of tabindex can also influence the order of the tab sequence, although authors are strongly advised not to use tabindex for that purpose. -

- -

- In HTML, the default tab sequence of a web page includes only links and HTML form elements, except In macOS, where it includes only form elements. - macOS system preferences include a keyboard setting that enables the tab key to move focus to all focusable elements. -

- -

- The default order of elements in the tab sequence is the order of elements in the DOM. - The DOM order also determines screen reader reading order. - It is important to keep the keyboard tab sequence and the screen reader reading order aligned, logical, and predictable as described in . - The most robust method of manipulating the order of the tab sequence while also maintaining alignment with the reading order that is currently available in all browsers is rearranging elements in the DOM. -

- -

The values of the tabindex attribute have the following effects.

- -
-
tabindex is not present or does not have a valid value
-
- The element has its default focus behavior. - In HTML, only form controls and anchors with an HREF attribute are included in the tab sequence. -
-
tabindex="0"
-
The element is included in the tab sequence based on its position in the DOM.
-
tabindex="-1"
-
The element is not included in the tab sequence but is focusable with element.focus().
-
tabindex="X" where X is an integer in the range 1 <= X <= 32767
-
- Authors are strongly advised NOT to use these values. - The element is placed in the tab sequence based on the value of tabindex. - Elements with a tabindex value of 0 and elements that are focusable by default will be in the sequence after elements with a tabindex value of 1 or greater. -
-
-
- -
-

Keyboard Navigation Inside Components

- -

- As described in section , the tab sequence should include only one focusable element of a composite UI component. - Once a composite contains focus, keys other than Tab and Shift + Tab enable the user to move focus among its focusable elements. - Authors are free to choose which keys move focus inside of a composite, but they are strongly advised to use the same key bindings as similar components in common GUI operating systems as demonstrated in . -

- -

The convention for where focus lands in a composite when it receives focus as a result of a Tab key event depends on the type of composite. It is typically one of the following.

- - - -

- The following sections explain two strategies for managing focus inside composite elements: creating a roving tabindex and using the aria-activedescendant property. -

- -
-

Managing Focus Within Components Using a Roving tabindex

- -

- When using roving tabindex to manage focus in a composite UI component, the element that is to be included in the tab sequence has tabindex of "0" and all other focusable elements contained in the composite have tabindex of "-1". - The algorithm for the roving tabindex strategy is as follows. -

- -
    -
  • When the component container is loaded or created, set tabindex="0" on the element that will initially be included in the tab sequence and set tabindex="-1" on all other focusable elements it contains.
  • -
  • - When the component contains focus and the user presses a navigation key that moves focus within the component, such as an arrow key: - -
      -
    • set tabindex="-1" on the element that has tabindex="0".
    • -
    • Set tabindex="0" on the element that will become focused as a result of the key event.
    • -
    • Set focus, element.focus(), on the element that has tabindex="0".
    • -
    -
  • - -
  • - If the design calls for a specific element to be focused the next time the user moves focus into the composite with Tab or Shift+Tab, check if that target element has tabindex="0" when the composite loses focus. - If it does not, set tabindex="0" on the target element and set tabindex="-1" on the element that previously had tabindex="0". -
  • -
- -

- One benefit of using roving tabindex rather than aria-activedescendant to manage focus is that the user agent will scroll the newly focused element into view. -

-
- -
-

Managing Focus in Composites Using aria-activedescendant

- -

- If a component container has an ARIA role that supports the aria-activedescendant property, it is not necessary to manipulate the tabindex attribute and move DOM focus among focusable elements within the container. - Instead, only the container element needs to be included in the tab sequence. When the container has DOM focus, the value of aria-activedescendant on the container tells assistive technologies which element is active within the widget. - Assistive technologies will consider the element referred to as active to be the focused element even though DOM focus is on the element that has the aria-activedescendant property. - And, when the value of aria-activedescendant is changed, assistive technologies will receive focus change events equivalent to those received when DOM focus actually moves. -

- -

The steps for using the aria-activedescendant method of managing focus are as follows.

- -
    -
  • When the container element that has a role that supports aria-activedescendant is loaded or created, ensure that: -
      -
    • The container element is included in the tab sequence as described in or is a focusable element of a composite that implements a roving tabindex.
    • -
    • - It has aria-activedescendant="IDREF" where IDREF is the ID of the element within the container that should be identified as active when the widget receives focus. - The referenced element needs to meet the DOM relationship requirements described below. -
    • -
    -
  • -
  • When the container element receives DOM focus, draw a visual focus indicator on the active element and ensure the active element is scrolled into view.
  • -
  • When the composite widget contains focus and the user presses a navigation key that moves focus within the widget, such as an arrow key: -
      -
    • Change the value of aria-activedescendant on the container to refer to the element that should be reported to assistive technologies as active.
    • -
    • Move the visual focus indicator and, if necessary, scrolled the active element into view.
    • -
    -
  • -
  • - If the design calls for a specific element to be focused the next time a user moves focus into the composite with Tab or Shift+Tab, check if aria-activedescendant is referring to that target element when the container loses focus. - If it is not, set aria-activedescendant to refer to the target element. -
  • -
- -

- The specification for aria-activedescendant places important restrictions on the DOM relationship between the focused element that has the aria-activedescendant attribute and the element referenced as active by the value of the attribute. - One of the following three conditions must be met. -

-
    -
  1. The element referenced as active is a DOM descendant of the focused referencing element.
  2. -
  3. The focused referencing element has a value specified for the aria-owns property that includes the ID of the element referenced as active.
  4. -
  5. The focused referencing element has role of combobox, textbox, or searchbox and has aria-controls property referring to an element with a role that supports aria-activedescendant and either: -
      -
    1. The element referenced as active is a descendant of the controlled element.
    2. -
    3. The controlled element has a value specified for the aria-owns property that includes the ID of the element referenced as active.
    4. -
    -
  6. -
-
-
-
-

Focusability of disabled controls

-

- By default, disabled HTML input elements are removed from the tab sequence. - In most contexts, the normal expectation is that disabled interactive elements are not focusable. - However, there are some contexts where it is common for disabled elements to be focusable, especially inside of composite widgets. - For example, as demonstrated in the pattern, disabled items are focusable when navigating through a menu with the arrow keys. -

- -

- Removing focusability from disabled elements can offer users both advantages and disadvantages. - Allowing keyboard users to skip disabled elements usually reduces the number of key presses required to complete a task. - However, preventing focus from moving to disabled elements can hide their presence from screen reader users who "see" by moving the focus. -

- -

- Authors are encouraged to adopt a consistent set of conventions for the focusability of disabled elements. - The examples in this guide adopt the following conventions, which both reflect common practice and attempt to balance competing concerns. -

- -
    -
  1. For elements that are in the tab sequence when enabled, remove them from the tab sequence when disabled.
  2. - -
  3. - For the following composite widget elements, keep them focusable when disabled: - - -
  4. - -
  5. - For elements contained in a toolbar, make them focusable if discoverability is a concern. Here are two examples to aid with this judgment. - -
      -
    1. - A toolbar with buttons for moving, removing, and adding items in a list includes buttons for "Up", "Down", "Add", and "Remove". - The "Up" button is disabled and its focusability is removed when the first item in the list is selected. - Given the presence of the "Down" button, discoverability of the "Up" button is not a concern. -
    2. - -
    3. - A toolbar in an editor contains a set of special smart paste functions that are disabled when the clipboard is empty or when the function is not applicable to the current content of the clipboard. - It could be helpful to keep the disabled buttons focusable if the ability to discover their functionality is primarily via their presence on the toolbar. -
    4. -
    -
  6. -
- -

One design technique for mitigating the impact of including disabled elements in the path of keyboard focus is employing appropriate keyboard shortcuts as described in .

-
-
-

Key Assignment Conventions for Common Functions

-

- The following key assignments can be used in any context where their conventionally associated functions are appropriate. - While the assignments associated with Windows and Linux platforms can be implemented and used in browsers running in macOS, - replacing them with macOS assignments in browsers running on a macOS device can make the keyboard interface more discoverable and intuitive for those users. - In some cases, it may also help avoid system or browser keyboard conflicts. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionWindows/Linux KeymacOS Key
open context menuShift + F10
Copy to clipboardControl + CCommand + C
Paste from clipboardControl + VCommand + V
Cut to clipboardControl + XCommand + X
undo last actionControl + ZCommand + Z
Redo actionControl + YCommand + Shift + Z
-
-
-

Keyboard Shortcuts

-

- When effectively designed, keyboard shortcuts that focus an element, activate a widget, or both can dramatically enhance usability of frequently used features of a page or site. - This section addresses some of the keyboard shortcut design and implementation factors that most impact their effectiveness, including: -

-
    -
  1. Understanding how keyboard shortcuts augment a keyboard interface and whether to make a particular shortcut move focus, perform a function, or both.
  2. -
  3. Making key assignments and avoiding assignment conflicts with assistive technologies, browsers, and operating systems.
  4. -
  5. Exposing and documenting key assignments.
  6. -
-
-

Designing the Scope and Behavior of Keyboard Shortcuts

- -

This section explains the following factors when determining which elements and features to assign keyboard shortcuts and what behavior to give each shortcut:

- -
    -
  1. Ensuring discovery through navigation; keyboard shortcuts enhance, not replace, standard keyboard access.
  2. - -
  3. - Effectively choosing from among the following behaviors: - -
      -
    1. Navigation: Moving focus to an element.
    2. -
    3. Activation: Performing an operation associated with an element that does not have focus and might not be visible.
    4. -
    5. Navigation and activation: Both moving focus to an element and activating it.
    6. -
    -
  4. - -
  5. Balancing efficiency and cognitive load: lack of a shortcut can reduce efficiency while too many shortcuts can increase cognitive load and clutter the experience.
  6. -
- -
-
Ensure Basic Access Via Navigation
- -

- Before assigning keyboard shortcuts, it is essential to ensure the features and functions to which shortcuts may be assigned are keyboard accessible without a keyboard shortcut. - In other words, all elements that could be targets for keyboard shortcuts need to be focusable via the keyboard using the methods described in: -

- -
    -
  • -
  • -
- -

- Do not use keyboard shortcuts as a substitute for access via navigation. - This is essential to full keyboard access because: -

- -
    -
  1. The primary means of making functions and their shortcuts discoverable is by making the target elements focusable and revealing key assignments on the element itself.
  2. -
  3. If people who rely on the keyboard have to read documentation to learn which keys are required to use an interface, the interface may technically meet some accessibility standards but in practice is only accessible to the small subset of them who have the knowledge that such documentation exists, have the extra time available, and the ability to retain the necessary information.
  4. -
  5. Not all devices that depend on keyboard interfaces can support keyboard shortcuts.
  6. -
-
- -
-
Choose Appropriate Shortcut Behavior
- -

The following conventions may help identify the most advantageous behavior for a keyboard shortcut.

- -
    -
  • - Move focus when the primary objective is to make navigation more efficient, e.g., reduce the number of times the user must press Tab or the arrow keys. - This behavior is commonly expected when assigning a shortcut to a text box, toolbar, or composite, such as a listbox, tree, grid, or menubar. - This behavior is also useful for moving focus to a section of a page, such as the main content or a complementary landmark section. -
  • - -
  • Activate an element without moving focus when the target context of the function is the context that contains the focus. This behavior is most common for command buttons and for functions associated with elements that are not visible, such as a "Save" option that is accessible via a menu. For example, if the focus is on an option in a listbox and a toolbar contains buttons for moving and removing options, it is most beneficial to keep focus in the listbox when the user presses a key shortcut for one of the buttons in the toolbar. This behavior can be particularly important for screen reader users because it provides confirmation of the action performed and makes performing multiple commands more efficient. For instance, when a screen reader user presses the shortcut for the "Up" button, the user will be able to hear the new position of the option in the list since it still has the focus. Similarly, when the user presses the shortcut for deleting an option, the user can - hear the next option in the list and immediately decide whether to press the delete shortcut again.
  • - -
  • - Move focus and activate when the target of the shortcut has a single function and the context of that function is the same as the target. - This behavior is typical when a shortcut is assigned to a button that opens a menu or dialog, to a checkbox, or to a navigation link or button. -
  • -
-
- -
-
Choose Where to Add Shortcuts
-

Work to draft content for this section is tracked in issue 219.

-

The first goal when designing a keyboard interface is simple, efficient, and intuitive operation with only basic keyboard navigation support. If basic operation of a keyboard interface is inefficient, attempting to compensate for fundamental design issues, such as suboptimal layout or command structure, by implementing keyboard shortcuts will not likely reduce user frustration. The practical implication of this is that, in most well-designed user interfaces, the percentage of functionality that needs to be accessible via a keyboard shortcut in order to create optimal usability is not very high. In many simple user interfaces, keyboard shortcuts can be entirely superfluous. And, in user interfaces with too many keyboard shortcuts, the excess shortcuts create cognitive load that make the most useful ones more difficult to remember.

-

Consider the following when deciding where to assign keyboard shortcuts:

- -
    -
  1. To be written.
  2. -
-
-
-
-

Assigning Keyboard Shortcuts

-

When choosing the keys to assign to a shortcut, there are many factors to consider.

-
    -
  • Making the shortcut easy to learn and remember by using a mnemonic (e.g., Control + S for "Save") or following a logical or spacial pattern.
  • -
  • Localizing the interface, including for differences in which keys are available and how they behave and for language considerations that could impact mnemonics.
  • -
  • Avoiding and managing conflicts with key assignments used by an assistive technology, the browser, or the operating system.
  • -
-

- Methods for designing a key shortcut scheme that supports learning and memory is beyond the scope of this guide. - Unless the key shortcut scheme is extensive, it is likely sufficient to mimic concepts that are familiar from common desktop software, such as browsers. - Similarly, while localization is important, describing how to address it is left to other resources that specialize in that topic. -

-

- The remainder of this section provides guidance balancing requirements and concerns related to key assignment conflicts. - It is typically ideal if key assignments do not conflict with keys that are assigned to functions in the user's operating system, browser, or assistive technology. - Conflicts can block efficient access to functions that are essential to the user, and a perfect storm of conflicts can trap a user. - At the same time, there are some circumstances where intentional conflicts are useful. - And, given the vast array of operating system, browser, and assistive technology keys, it is almost impossible to be certain conflicts do not exist. - So it is also important to employ strategies that mitigate the impact of conflicts whether they are intentional or unknown. -

-

- In the following sections, meta key refers to the Windows key on Windows-compatible keyboards and the Command key on MacOS-compatible keyboards. -

-
-
Operating System Key Conflicts
- -

It is essential to avoid conflicts with keys that perform system level functions, such as application and window management and display and sound control. In general, this can be achieved by refraining from the following types of assignments.

- -
    -
  1. Any modifier keys + any of Tab, Enter, Space, or Escape.
  2. - -
  3. Meta key + any other single key (there are exceptions, but they can be risky as these keys can change across versions of operating systems).
  4. - -
  5. Alt + a function key.
  6. -
- -

- In addition, there are some important application level features that most applications, including browsers, generally support. - These include: -

- -
    -
  1. Zoom
  2. -
  3. Copy/Paste
  4. -
  5. ... to be continued ...
  6. -
-
- -
-
Assistive Technology Key Conflicts
- -

- Even though assistive technologies have collectively taken thousands of key assignments, avoiding conflicts is relatively easy. - This is because assistive technologies have had to develop key assignment schemes that avoid conflicts with both operating systems and applications. - They do this by hijacking specific keys as modifiers that uniquely define their key commands. - For example, many assistive technologies use the Caps Lock key as a modifier. -

- -

Deflect assistive technology key conflicts by steering clear of the following types of assignments.

- -
    -
  1. Caps Lock + any other combination of keys.
  2. -
  3. Insert + any combination of other keys.
  4. -
  5. Scroll Lock + any combination of other keys.
  6. -
  7. macOS only: Control+Option + any combination of other keys.
  8. -
-
- -
-
Browser Key Conflicts
- -

While there is considerable similarity among browser keyboard schemes, the patterns within the schemes are less homogenous. Consequently, it is more difficult to avoid conflicts with browser key assignments. While the impact of conflicts is sometimes mitigated by the availability of two paths to nearly every function -- keyboard accessible menus and keyboard shortcuts, avoiding conflicts with shortcuts to heavily used functions is nonetheless important. Pay special attention to avoiding conflicts with shortcuts to:

- -
    -
  1. Address or location bar
  2. -
  3. Notification bar
  4. -
  5. Page refresh
  6. -
  7. Bookmark and history functions
  8. -
  9. Find functions
  10. -
-
-
-
Intentional Key Conflicts
- -

- While avoiding key conflicts is usually desirable, there are circumstances where intentionally conflicting with a browser function is acceptable or even desirable. - This can occur when the following combination of conditions arises: -

- -
    -
  • A web application has a frequently used function that is similar to a browser function.
  • -
  • Users will often want to execute the web application function.
  • -
  • Users will rarely execute the browser function.
  • -
  • There is an efficient, alternative path to the browser function.
  • -
- -

For example, consider a save function that is available when the focus is in an editor. Most browsers use ... to be continued ...

-
-
-
-
- -
-

Grid and Table Properties

-

- To fully present and describe a grid or table, in addition to parsing the headers, rows, and cells using the roles described in the - grid pattern or table pattern, - assistive technologies need to be able to determine: -

- -

- Browsers automatically populate their accessibility tree with the number of rows and columns in a grid or table based on the rendered DOM. - However, there are many situations where the DOM does not contain the whole grid or table, such as when the data set is too large to fully render. - Additionally, some of this information, like skipped columns or rows and how data is sorted, cannot be derived from the DOM structure. -

-

The below sections explain how to use the following properties that ARIA provides for grid and table accessibility.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Grid and Table Property Definitions
PropertyDefinition
aria-colcountDefines the total number of columns in a table, grid, or treegrid.
aria-rowcountDefines the total number of rows in a table, grid, or treegrid.
aria-colindex -
    -
  • Defines a cell's position with respect to the total number of columns within a table, grid, or treegrid.
  • -
  • Note: Numbering starts with 1, not 0.
  • -
-
aria-rowindex -
    -
  • Defines a cell's position with respect to the total number of rows within a table, grid, or treegrid.
  • -
  • Note: Numbering starts with 1, not 0.
  • -
-
aria-colspanDefines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
aria-rowspanDefines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
aria-sortIndicates if items in a row or column are sorted in ascending or descending order.
-
-

Using aria-rowcount and aria-rowindex

-

- When the number of rows represented by the DOM structure is not the total number of rows available for a table, grid, or treegrid, - the aria-rowcount property is used to communicate the total number of rows available, - and it is accompanied by the aria-rowindex property to identify the row indices of the rows that are present in the DOM. -

-

- The aria-rowcount is specified on the element with the table, grid, or treegrid role. - Its value is an integer equal to the total number of rows available, including header rows. - If the total number of rows is unknown, a value of -1 may be specified. - Using a value of -1 indicates that more rows are available to include in the DOM without specifying the size of the available supply. -

-

- When aria-rowcount is used on a table, grid, or treegrid, - a value for aria-rowindex property is specified on each of its descendant rows, including any header rows. - The value of aria-rowindex is an integer that is: -

-
    -
  1. Greater than or equal to 1.
  2. -
  3. Greater than the value of aria-rowindex on any previous rows.
  4. -
  5. Set to the index of the first row in the span if cells span multiple rows.
  6. -
  7. Less than or equal to the total number of rows.
  8. -
-

- WARNING! Missing or inconsistent values of aria-rowindex could have devastating effects on assistive technology behavior. - For example, specifying an invalid value for aria-rowindex or setting it on some but not all rows in a table, could cause screen reader table reading functions to skip rows or simply stop functioning. -

-

- The following code demonstrates the use of aria-rowcount and aria-rowindex properties on a table containing a hypothetical class list. -

-
-        
-          <!--
-            aria-rowcount tells assistive technologies the actual size of the grid
-            is 463 rows even though only 4 rows are present in the markup.
-          -->
-          <table role="grid" aria-rowcount="463">
-            aria-label="Student roster for history 101"
-            <thead>
-              <tr aria-rowindex="1">
-                <th>Last Name</th>
-                <th>First Name</th>
-                <th>E-mail</th>
-                <th>Major</th>
-                <th>Minor</th>
-                <th>Standing</th>
-              </tr>
-            </thead>
-            <tbody>
-                <!--
-                  aria-rowindex tells assistive technologies that this
-                  row is row 51 in the grid of 463 rows.
-                -->
-              <tr aria-rowindex="51">
-                <td>Henderson</td>
-                <td>Alan</td>
-                <td>ahederson56@myuniveristy.edu</td>
-                <td>Business</td>
-                <td>Spanish</td>
-                <td>Junior</td>
-              </tr>
-                <!--
-                  aria-rowindex tells assistive technologies that this
-                  row is row 52 in the grid of 463 rows.
-                -->
-              <tr aria-rowindex="52">
-                <td>Henderson</td>
-                <td>Alice</td>
-                <td>ahederson345@myuniveristy.edu</td>
-                <td>Engineering</td>
-                <td>none</td>
-                <td>Sophomore</td>
-              </tr>
-                <!--
-                  aria-rowindex tells assistive technologies that this
-                  row is row 53 in the grid of 463 rows.
-                -->
-              <tr aria-rowindex="53">
-                <td>Henderson</td>
-                <td>Andrew</td>
-                <td>ahederson75@myuniveristy.edu</td>
-                <td>General Studies</td>
-                <td>none</td>
-                <td>Freshman</td>
-              </tr>
-            </tbody>
-          </table>
-        
-      
-
-
-

Using aria-colcount and aria-colindex

-

- When the number of columns represented by the DOM structure is not the total number of columns available for a table, grid, or treegrid, - the aria-colcount property is used to communicate the total number of columns available, - and it is accompanied by the aria-colindex property to identify the column indices of the columns that are present in the DOM. -

-

- The aria-colcount is specified on the element with the table, grid, or treegrid role. - Its value is an integer equal to the total number of columns available. - If the total number of columns is unknown, a value of -1 may be specified. - Using a value of -1 indicates that more columns are available to include in the DOM without specifying the size of the available supply. -

-

- When aria-colcount is used on a table, grid, or treegrid, - a value for aria-colindex property is either specified on each of its descendant rows or on every cell in each descendant row, depending on whether the columns are contiguous as described below. - The value of aria-colindex is an integer that is: -

-
    -
  1. Greater than or equal to 1.
  2. -
  3. When set on a cell, greater than the value set on any previous cell within the same row.
  4. -
  5. Set to the index of the first column in the span if a cell spans multiple columns.
  6. -
  7. Less than or equal to the total number of columns.
  8. -
-

- WARNING! Missing or inconsistent values of aria-colindex could have devastating effects on assistive technology behavior. - For example, specifying an invalid value for aria-colindex or setting it on some but not all cells in a row, could cause screen reader table reading functions to skip cells or simply stop functioning. -

-
-

Using aria-colindex When Column Indices Are Contiguous

-

- When all the cells in a row have column index numbers that are consecutive integers, - aria-colindex can be set on the row element with a value equal to the index number of the first column in the set. - Browsers will then compute a column number for each cell in the row. -

-

- The following code shows a grid with 16 columns, of which columns 2 through 5 are displayed to the user. - Because the set of columns is contiguous, aria-colindex can be placed on each row. -

-
-        
-<div role="grid" aria-colcount="16">
-  <div role="rowgroup">
-    <div role="row" aria-colindex="2">
-      <span role="columnheader">First Name</span>
-      <span role="columnheader">Last Name</span>
-      <span role="columnheader">Company</span>
-      <span role="columnheader">Address</span>
-    </div>
-  </div>
-  <div role="rowgroup">
-    <div role="row" aria-colindex="2">
-      <span role="gridcell">Fred</span>
-      <span role="gridcell">Jackson</span>
-      <span role="gridcell">Acme, Inc.</span>
-      <span role="gridcell">123 Broad St.</span>
-    </div>
-    <div role="row" aria-colindex="2">
-      <span role="gridcell">Sara</span>
-      <span role="gridcell">James</span>
-      <span role="gridcell">Acme, Inc.</span>
-      <span role="gridcell">123 Broad St.</span>
-    </div>
-   …
-  </div>
-</div>
-
-
-
-
-

Using aria-colindex When Column Indices Are Not Contiguous

-

- When the cells in a row have column index numbers that are not consecutive integers, aria-colindex needs to be set on each cell in the row. - The following example shows a grid for an online grade book where the first two columns contain a student name and subsequent columns contain scores. - In this example, the first two columns with the student name are shown, but the score columns have been scrolled to show columns 10 through 13. - Columns 3 through 9 are not visible so are not in the DOM. -

-
-          
-            <table role="grid" aria-rowcount="463" aria-colcount="13">
-              aria-label="Student grades for history 101"
-              <!--
-                aria-rowcount and aria-colcount tell assistive technologies
-                the actual size of the grid is 463 rows by 13 columns,
-                which is not the number rows and columns found in the markup.
-              -->
-              <thead>
-                <tr aria-rowindex="1">
-                  <!--
-                    aria-colindex tells assistive technologies that the
-                    following columns represent columns 1 and 2 of the total data set.
-                  -->
-                  <th aria-colindex="1">Last Name</th>
-                  <th aria-colindex="2">First Name</th>
-                  <!--
-                    aria-colindex tells users of assistive technologies that the
-                    following columns represent columns 10, 11, 12, and 13 of
-                    the overall data set of grades.
-                  -->
-                  <th aria-colindex="10">Homework 4</th>
-                  <th aria-colindex="11">Quiz 2</th>
-                  <th aria-colindex="12">Homework 5</th>
-                  <th aria-colindex="13">Homework 6</th>
-                </tr>
-              </thead>
-              <tbody>
-                <tr aria-rowindex="50">
-                  <!--
-                    every cell needs to define the aria-colindex attribute
-                  -->
-                  <td aria-colindex="1">Henderson</td>
-                  <td aria-colindex="2">Alan</td>
-                  <td aria-colindex="10">8</td>
-                  <td aria-colindex="11">25</td>
-                  <td aria-colindex="12">9</td>
-                  <td aria-colindex="13">9</td>
-                </tr>
-                <tr aria-rowindex="51">
-                  <td aria-colindex="1">Henderson</td>
-                  <td aria-colindex="2">Alice</td>
-                  <td aria-colindex="10">10</td>
-                  <td aria-colindex="11">27</td>
-                  <td aria-colindex="12">10</td>
-                  <td aria-colindex="13">8</td>
-                </tr>
-                <tr aria-rowindex="52">
-                  <td aria-colindex="1">Henderson</td>
-                  <td aria-colindex="2">Andrew</td>
-                  <td aria-colindex="10">9</td>
-                  <td aria-colindex="11">0</td>
-                  <td aria-colindex="12">29</td>
-                  <td aria-colindex="13">8</td>
-                </tr>
-              </tbody>
-            </table>
-          
-        
-
-
-
-

Defining cell spans using aria-colspan and aria-rowspan

-

- For tables, grids, and treegrids created using elements other than HTML table elements, - row and column spans are defined with the aria-rowspan and aria-colspan properties. -

-

The value of aria-colspan is an integer that is:

-
    -
  1. Greater than or equal to 1.
  2. -
  3. less than the value that would cause the cell to overlap the next cell in the same row.
  4. -
-

The value of aria-rowspan is an integer that is:

-
    -
  1. Greater than or equal to 0.
  2. -
  3. 0 means the cell spans all the remaining rows in its row group.
  4. -
  5. less than the value that would cause the cell to overlap the next cell in the same column.
  6. -
-

- The following example grid has a two row header. - The first two columns have headers that span both rows of the header. - The subsequent 6 columns are grouped into 3 pairs with headers in the first row that each span two columns. -

-
-        
-          <div role="grid" aria-rowcount="463">
-            aria-label="Student grades for history 101"
-            <div role="rowgroup">
-              <div role="row" aria-rowindex="1">
-                  <!--
-                    aria-rowspan and aria-colspan provide
-                    assistive technologies with the correct data cell header information
-                    when header cells span more than one row or column.
-                  -->
-                  <span role="columnheader" aria-rowspan="2">Last Name</span>
-                  <span role="columnheader" aria-rowspan="2">First Name</span>
-                  <span role="columnheader" aria-colspan="2">Test 1</span>
-                  <span role="columnheader" aria-colspan="2">Test 2</span>
-                  <span role="columnheader" aria-colspan="2">Final</span>
-              </div>
-              <div role="row" aria-rowindex="2">
-                  <span role="columnheader">Score</span>
-                  <span role="columnheader">Grade</span>
-                  <span role="columnheader">Score</span>
-                  <span role="columnheader">Grade</span>
-                  <span role="columnheader">Total</span>
-                  <span role="columnheader">Grade</span>
-              </div>
-            </div>
-            <div role="rowgroup">
-              <div role="row" aria-rowindex="50">
-                <span role="cell">Henderson</span>
-                <span role="cell">Alan</span>
-                <span role="cell">89</span>
-                <span role="cell">B+</span>
-                <span role="cell">72</span>
-                <span role="cell">C</span>
-                <span role="cell">161</span>
-                <span role="cell">B-</span>
-              </div>
-              <div role="row" aria-rowindex="51">
-                <span role="cell">Henderson</span>
-                <span role="cell">Alice</span>
-                <span role="cell">94</span>
-                <span role="cell">A</span>
-                <span role="cell">86</span>
-                <span role="cell">B</span>
-                <span role="cell">180</span>
-                <span role="cell">A-</span>
-              </div>
-              <div role="row" aria-rowindex="52">
-                <span role="cell">Henderson</span>
-                <span role="cell">Andrew</span>
-                <span role="cell">82</span>
-                <span role="cell">B-</span>
-                <span role="cell">95</span>
-                <span role="cell">A</span>
-                <span role="cell">177</span>
-                <span role="cell">B+</span>
-              </div>
-            </div>
-          </div>
-        
-      
-

- Note: When using HTML table elements, - use the native semantics of the th and td elements to define row and column spans - by using the rowspan and colspan attributes. -

-
-
-

Indicating sort order with aria-sort

-

- When rows or columns are sorted, the aria-sort property can be applied to a column or row header to indicate the sorting method. - The following table describes allowed values for aria-sort. -

- - - - - - - - - - - - - - - - - - - - - - - - - - -
- Description of values for aria-sort -
ValueDescription
ascendingData are sorted in ascending order.
descendingData are sorted in descending order.
otherData are sorted by an algorithm other than ascending or descending.
noneDefault (no sort applied).
-

- It is important to note that ARIA does not provide a way to indicate levels of sort for data sets that have multiple sort keys. - Thus, there is limited value to applying aria-sort with a value other than none to more than one column or row. -

-

The following example grid uses aria-sort to indicate the rows are sorted from the highest "Quiz 2" score to the lowest "Quiz 2" score.

-
-        
-          <table role="grid" aria-rowcount="463" aria-colcount="13"
-            aria-label="Student grades for history 101">
-            <thead>
-              <tr aria-colindex="10" aria-rowindex="1">
-                <th>Homework 4</th>
-                <!--
-                  aria-sort indicates the column with the heading
-                  "Quiz 2" has been used to sort the rows of the grid.
-                -->
-                <th aria-sort="descending">Quiz 2</th>
-                <th>Homework 5</th>
-                <th>Homework 6</th>
-              </tr>
-            </thead>
-            <tbody>
-              <tr aria-colindex="10" aria-rowindex="50">
-                <td>8</td>
-                <td>30</td>
-                <td>9</td>
-                <td>9</td>
-              </tr>
-              <tr aria-colindex="10"  aria-rowindex="51">
-                <td>10</td>
-                <td>29</td>
-                <td>10</td>
-                <td>8</td>
-              </tr>
-              <tr aria-colindex="10"  aria-rowindex="52">
-                <td>9</td>
-                <td>9</td>
-                <td>27</td>
-                <td>6</td>
-              </tr>
-              <tr aria-colindex="10"  aria-rowindex="53">
-                <td>9</td>
-                <td>10</td>
-                <td>26</td>
-                <td>8</td>
-              </tr>
-              <tr aria-colindex="10"  aria-rowindex="54">
-                <td>9</td>
-                <td>7</td>
-                <td>24</td>
-                <td>6</td>
-              </tr>
-            </tbody>
-          </table>
-        
-      
- - -
- -
- - - -
-

Intentionally Hiding Semantics with the presentation Role

-

- While ARIA is primarily used to express semantics, there are some situations where hiding an - element’s semantics from assistive technologies is helpful. This is done with the - presentation - role, which declares that an element is being used only for presentation and therefore does - not have any accessibility semantics. The ARIA 1.1 specification also includes role - none, - which serves as a synonym for presentation. -

-

- For example, consider a tabs widget built using an HTML ul element. -

-
-    <ul role="tablist">
-      <li role="presentation">
-        <a role="tab" href="#">Tab 1</a>
-      </li>
-      <li role="presentation">
-        <a role="tab" href="#">Tab 2</a>
-      </li>
-      <li role="presentation">
-        <a role="tab" href="#">Tab 3</a>
-      </li>
-    </ul>
-    
-

- Because the list is declared to be a tablist, the list items are not in a list context. It - could confuse users if an assistive technology were to render those list items. Applying role - presentation to the li elements tells browsers to leave those - elements out of their accessibility tree. Assistive technologies will thus be unaware of the - list item elements and see the tab elements as immediate children of the tablist. -

-

- Three common uses of role presentation are: -

-
    -
  1. Hiding a decorative image; it is equivalent to giving the image null alt text.
  2. -
  3. Suppressing table semantics of tables used for layout in circumstances where the table semantics do not convey meaningful relationships.
  4. -
  5. Eliminating semantics of intervening orphan elements in the structure of a composite - widget, such as a tablist, menu, or tree as demonstrated in the example above.
  6. -
-
-

- Effects of Role presentation -

-

- When role="presentation" is specified on an element, if a - condition that requires a browser to ignore the presentation role - does not exist, it has the following three effects. -

-
    -
  1. The element’s implied ARIA role and any ARIA states and properties associated with - that role are hidden from assistive technologies.
  2. -
  3. - Text contained by the element, i.e., inner text, as well as inner text of all its - descendant elements remains visible to assistive technologies except, of course, when the - text is explicitly hidden, e.g., styled with display: none or has aria-hidden="true". -
  4. -
  5. - The roles, states, and properties of each descendant element remain visible to assistive - technologies unless the descendant requires the context of the presentational - element. For example: -
      -
    • If presentation is applied to a ul or ol element, each child li element inherits the presentation role because ARIA requires the listitem elements to have the parent list element. So, the li elements are not exposed to assistive technologies, but elements contained inside of those li elements, including nested lists, are visible to assistive technologies.
    • -
    • - Similarly, if presentation is applied to a table element, - the descendant caption, thead, tbody, tfoot, - tr, th, and td - elements inherit role presentation and are thus not exposed to assistive technologies. - But, elements inside of the th and td elements, including nested tables, are exposed to assistive technologies. -
    • -
    -
  6. -
-
-
-

- Conditions That Cause Role presentation to be Ignored -

-

- Browsers ignore role="presentation", and it therefore has no effect, if either of the following are true about the element to which it is applied:

- -
-
-

- Example Demonstrating Effects of the presentation Role -

-

This code:

-
-        <ul role="presentation">
-          <li>Date of birth:</li>
-          <li>January 1, 3456</li>
-        </ul>
-      
-

when parsed by a browser, is equivalent to the following from the perspective of a screen reader or other assistive technology that relies on the browser's accessibility tree: -

-
-        <div>Date of birth:</div>
-          <div>January 1, 3456</div>
-      
-
-
- -
-

Roles That Automatically Hide Semantics by Making Their Descendants Presentational

-

- There are some types of user interface components that, when represented in a platform - accessibility API, can only contain text. For example, accessibility APIs do not have a way of - representing semantic elements contained in a button. To deal with this limitation, WAI-ARIA - requires browsers to automatically apply role presentation to all descendant - elements of any element with a role that cannot support semantic children. -

-

The roles that require all children to be presentational are:

- -

For instance, consider the following tab element, which contains a heading.

-
-      <li role="tab"><h3>Title of My Tab</h3></li>
-    
-

- Because WAI-ARIA requires descendants of tab to be presentational, - the following code is equivalent. -

-
-      <li role="tab"><h3 role="presentation">Title of My Tab</h3></li>
-    
-

- And, from the perspective of anyone using a technology that relies on an accessibility API, such as a screen reader, - the heading does not exist since the previous code is equivalent to the following. -

-
-      <li role="tab">Title of My Tab</li>
-    
-

- See the - - section about role presentation - - for a detailed explanation of what it does. -

-
- -
-

Structural Roles

-

- ARIA provides a set of roles that convey the accessibility semantics of structures on a page. - These roles express the meaning that is conveyed by the layout and appearance of elements that organize and structure content, such as headings, lists, and tables. -

-

- some host languages, such as HTML, include elements that express the same semantics as an ARIA role. - For instance, the HTML <p> element is mapped to accessibility APIs in exactly the same way as <div role="paragraph">. - The ARIA and HTML specifications refer to this mapping of HTML elements to ARIA attributes as implied semantics, i.e., the implied ARIA role of the HTML <p> element is paragraph. -

-

- When developing HTML, it is important to use native HTML elements where ever possible. - Do not use an ARIA role or property if it is possible to use an HTML element that has equivalent semantics. - Circumstances where it is appropriate to use ARIA attributes instead of equivalent HTML are: -

-
    -
  1. When the HTML element cannot be styled in a way that meets visual design requirements.
  2. -
  3. When testing reveals that browsers or assistive technologies provide better support for the ARIA equivalent.
  4. -
  5. When remediating or retrofitting legacy content and altering the underlying DOM to use the HTML would be cost prohibitive.
  6. -
  7. When building a web component to compose a custom element and the element being extended does not convey the appropriate or sufficient accessibility semantics.
  8. -
-

The following table lists all structural roles defined in ARIA 1.2.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ARIA structural roles
ARIA RoleHTML Equivalent
applicationNo equivalent element
articlearticle
blockquoteblockquote
captioncaption
celltd
codecode
columnheaderth
definitiondd
deletiondel
directoryNo equivalent element
documentNo equivalent element
emphasisem
feedNo equivalent element
figurefigure
genericdiv, span
groupNo equivalent element
heading with aria-level="N" where N is 1, 2, 3, 4, 5, or 6h1, h2, h3, h4, h5, h6
insertionins
imgimg
listul, ol
listitemli
mathNo equivalent element
noneNo equivalent element
noteNo equivalent element
presentationNo equivalent element
paragraphp
rowtr
rowgrouptbody, thead, tfoot
rowheaderth
separator (when not focusable)hr
strongstrong
subscriptsub
superscriptsup
tabletable
termdfn
timetime
toolbarNo equivalent element
tooltipNo equivalent element
-

Indexes

diff --git a/content/practices/grid-and-table-properties/grid-and-table-properties-practice.html b/content/practices/grid-and-table-properties/grid-and-table-properties-practice.html new file mode 100644 index 0000000000..9f84ea6263 --- /dev/null +++ b/content/practices/grid-and-table-properties/grid-and-table-properties-practice.html @@ -0,0 +1,492 @@ + + + + + +Grid and Table Properties + + +

Grid and Table Properties

+
+

Introduction

+

+ To fully present and describe a grid or table, in addition to parsing the headers, rows, and cells using the roles described in the + grid pattern or table pattern, + assistive technologies need to be able to determine: +

+ +

+ Browsers automatically populate their accessibility tree with the number of rows and columns in a grid or table based on the rendered DOM. + However, there are many situations where the DOM does not contain the whole grid or table, such as when the data set is too large to fully render. + Additionally, some of this information, like skipped columns or rows and how data is sorted, cannot be derived from the DOM structure. +

+

The below sections explain how to use the following properties that ARIA provides for grid and table accessibility.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Grid and Table Property Definitions
PropertyDefinition
aria-colcountDefines the total number of columns in a table, grid, or treegrid.
aria-rowcountDefines the total number of rows in a table, grid, or treegrid.
aria-colindex +
    +
  • Defines a cell's position with respect to the total number of columns within a table, grid, or treegrid.
  • +
  • Note: Numbering starts with 1, not 0.
  • +
+
aria-rowindex +
    +
  • Defines a cell's position with respect to the total number of rows within a table, grid, or treegrid.
  • +
  • Note: Numbering starts with 1, not 0.
  • +
+
aria-colspanDefines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
aria-rowspanDefines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
aria-sortIndicates if items in a row or column are sorted in ascending or descending order.
+
+
+

Using aria-rowcount and aria-rowindex

+

+ When the number of rows represented by the DOM structure is not the total number of rows available for a table, grid, or treegrid, + the aria-rowcount property is used to communicate the total number of rows available, + and it is accompanied by the aria-rowindex property to identify the row indices of the rows that are present in the DOM. +

+

+ The aria-rowcount is specified on the element with the table, grid, or treegrid role. + Its value is an integer equal to the total number of rows available, including header rows. + If the total number of rows is unknown, a value of -1 may be specified. + Using a value of -1 indicates that more rows are available to include in the DOM without specifying the size of the available supply. +

+

+ When aria-rowcount is used on a table, grid, or treegrid, + a value for aria-rowindex property is specified on each of its descendant rows, including any header rows. + The value of aria-rowindex is an integer that is: +

+
    +
  1. Greater than or equal to 1.
  2. +
  3. Greater than the value of aria-rowindex on any previous rows.
  4. +
  5. Set to the index of the first row in the span if cells span multiple rows.
  6. +
  7. Less than or equal to the total number of rows.
  8. +
+

+ WARNING! Missing or inconsistent values of aria-rowindex could have devastating effects on assistive technology behavior. + For example, specifying an invalid value for aria-rowindex or setting it on some but not all rows in a table, could cause screen reader table reading functions to skip rows or simply stop functioning. +

+

+ The following code demonstrates the use of aria-rowcount and aria-rowindex properties on a table containing a hypothetical class list. +

+
+    
+      <!--
+        aria-rowcount tells assistive technologies the actual size of the grid
+        is 463 rows even though only 4 rows are present in the markup.
+      -->
+      <table role="grid" aria-rowcount="463">
+        aria-label="Student roster for history 101"
+        <thead>
+          <tr aria-rowindex="1">
+            <th>Last Name</th>
+            <th>First Name</th>
+            <th>E-mail</th>
+            <th>Major</th>
+            <th>Minor</th>
+            <th>Standing</th>
+          </tr>
+        </thead>
+        <tbody>
+            <!--
+              aria-rowindex tells assistive technologies that this
+              row is row 51 in the grid of 463 rows.
+            -->
+          <tr aria-rowindex="51">
+            <td>Henderson</td>
+            <td>Alan</td>
+            <td>ahederson56@myuniveristy.edu</td>
+            <td>Business</td>
+            <td>Spanish</td>
+            <td>Junior</td>
+          </tr>
+            <!--
+              aria-rowindex tells assistive technologies that this
+              row is row 52 in the grid of 463 rows.
+            -->
+          <tr aria-rowindex="52">
+            <td>Henderson</td>
+            <td>Alice</td>
+            <td>ahederson345@myuniveristy.edu</td>
+            <td>Engineering</td>
+            <td>none</td>
+            <td>Sophomore</td>
+          </tr>
+            <!--
+              aria-rowindex tells assistive technologies that this
+              row is row 53 in the grid of 463 rows.
+            -->
+          <tr aria-rowindex="53">
+            <td>Henderson</td>
+            <td>Andrew</td>
+            <td>ahederson75@myuniveristy.edu</td>
+            <td>General Studies</td>
+            <td>none</td>
+            <td>Freshman</td>
+          </tr>
+        </tbody>
+      </table>
+    
+  
+
+
+

Using aria-colcount and aria-colindex

+

+ When the number of columns represented by the DOM structure is not the total number of columns available for a table, grid, or treegrid, + the aria-colcount property is used to communicate the total number of columns available, + and it is accompanied by the aria-colindex property to identify the column indices of the columns that are present in the DOM. +

+

+ The aria-colcount is specified on the element with the table, grid, or treegrid role. + Its value is an integer equal to the total number of columns available. + If the total number of columns is unknown, a value of -1 may be specified. + Using a value of -1 indicates that more columns are available to include in the DOM without specifying the size of the available supply. +

+

+ When aria-colcount is used on a table, grid, or treegrid, + a value for aria-colindex property is either specified on each of its descendant rows or on every cell in each descendant row, depending on whether the columns are contiguous as described below. + The value of aria-colindex is an integer that is: +

+
    +
  1. Greater than or equal to 1.
  2. +
  3. When set on a cell, greater than the value set on any previous cell within the same row.
  4. +
  5. Set to the index of the first column in the span if a cell spans multiple columns.
  6. +
  7. Less than or equal to the total number of columns.
  8. +
+

+ WARNING! Missing or inconsistent values of aria-colindex could have devastating effects on assistive technology behavior. + For example, specifying an invalid value for aria-colindex or setting it on some but not all cells in a row, could cause screen reader table reading functions to skip cells or simply stop functioning. +

+
+

Using aria-colindex When Column Indices Are Contiguous

+

+ When all the cells in a row have column index numbers that are consecutive integers, + aria-colindex can be set on the row element with a value equal to the index number of the first column in the set. + Browsers will then compute a column number for each cell in the row. +

+

+ The following code shows a grid with 16 columns, of which columns 2 through 5 are displayed to the user. + Because the set of columns is contiguous, aria-colindex can be placed on each row. +

+
+
+<div role="grid" aria-colcount="16">
+  <div role="rowgroup">
+    <div role="row" aria-colindex="2">
+      <span role="columnheader">First Name</span>
+      <span role="columnheader">Last Name</span>
+      <span role="columnheader">Company</span>
+      <span role="columnheader">Address</span>
+    </div>
+  </div>
+  <div role="rowgroup">
+    <div role="row" aria-colindex="2">
+      <span role="gridcell">Fred</span>
+      <span role="gridcell">Jackson</span>
+      <span role="gridcell">Acme, Inc.</span>
+      <span role="gridcell">123 Broad St.</span>
+    </div>
+    <div role="row" aria-colindex="2">
+      <span role="gridcell">Sara</span>
+      <span role="gridcell">James</span>
+      <span role="gridcell">Acme, Inc.</span>
+      <span role="gridcell">123 Broad St.</span>
+    </div>
+   …
+  </div>
+</div>
+
+
+
+
+

Using aria-colindex When Column Indices Are Not Contiguous

+

+ When the cells in a row have column index numbers that are not consecutive integers, aria-colindex needs to be set on each cell in the row. + The following example shows a grid for an online grade book where the first two columns contain a student name and subsequent columns contain scores. + In this example, the first two columns with the student name are shown, but the score columns have been scrolled to show columns 10 through 13. + Columns 3 through 9 are not visible so are not in the DOM. +

+
+
+<table role="grid" aria-rowcount="463" aria-colcount="13">
+  aria-label="Student grades for history 101"
+  <!--
+    aria-rowcount and aria-colcount tell assistive technologies
+    the actual size of the grid is 463 rows by 13 columns,
+    which is not the number rows and columns found in the markup.
+  -->
+  <thead>
+    <tr aria-rowindex="1">
+      <!--
+        aria-colindex tells assistive technologies that the
+        following columns represent columns 1 and 2 of the total data set.
+      -->
+      <th aria-colindex="1">Last Name</th>
+      <th aria-colindex="2">First Name</th>
+      <!--
+        aria-colindex tells users of assistive technologies that the
+        following columns represent columns 10, 11, 12, and 13 of
+        the overall data set of grades.
+      -->
+      <th aria-colindex="10">Homework 4</th>
+      <th aria-colindex="11">Quiz 2</th>
+      <th aria-colindex="12">Homework 5</th>
+      <th aria-colindex="13">Homework 6</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr aria-rowindex="50">
+      <!--
+        every cell needs to define the aria-colindex attribute
+      -->
+      <td aria-colindex="1">Henderson</td>
+      <td aria-colindex="2">Alan</td>
+      <td aria-colindex="10">8</td>
+      <td aria-colindex="11">25</td>
+      <td aria-colindex="12">9</td>
+      <td aria-colindex="13">9</td>
+    </tr>
+    <tr aria-rowindex="51">
+      <td aria-colindex="1">Henderson</td>
+      <td aria-colindex="2">Alice</td>
+      <td aria-colindex="10">10</td>
+      <td aria-colindex="11">27</td>
+      <td aria-colindex="12">10</td>
+      <td aria-colindex="13">8</td>
+    </tr>
+    <tr aria-rowindex="52">
+      <td aria-colindex="1">Henderson</td>
+      <td aria-colindex="2">Andrew</td>
+      <td aria-colindex="10">9</td>
+      <td aria-colindex="11">0</td>
+      <td aria-colindex="12">29</td>
+      <td aria-colindex="13">8</td>
+    </tr>
+  </tbody>
+</table>
+
+
+
+
+
+

Defining cell spans using aria-colspan and aria-rowspan

+

+ For tables, grids, and treegrids created using elements other than HTML table elements, + row and column spans are defined with the aria-rowspan and aria-colspan properties. +

+

The value of aria-colspan is an integer that is:

+
    +
  1. Greater than or equal to 1.
  2. +
  3. less than the value that would cause the cell to overlap the next cell in the same row.
  4. +
+

The value of aria-rowspan is an integer that is:

+
    +
  1. Greater than or equal to 0.
  2. +
  3. 0 means the cell spans all the remaining rows in its row group.
  4. +
  5. less than the value that would cause the cell to overlap the next cell in the same column.
  6. +
+

+ The following example grid has a two row header. + The first two columns have headers that span both rows of the header. + The subsequent 6 columns are grouped into 3 pairs with headers in the first row that each span two columns. +

+
+
+  <div role="grid" aria-rowcount="463">
+    aria-label="Student grades for history 101"
+    <div role="rowgroup">
+      <div role="row" aria-rowindex="1">
+          <!--
+            aria-rowspan and aria-colspan provide
+            assistive technologies with the correct data cell header information
+            when header cells span more than one row or column.
+          -->
+          <span role="columnheader" aria-rowspan="2">Last Name</span>
+          <span role="columnheader" aria-rowspan="2">First Name</span>
+          <span role="columnheader" aria-colspan="2">Test 1</span>
+          <span role="columnheader" aria-colspan="2">Test 2</span>
+          <span role="columnheader" aria-colspan="2">Final</span>
+      </div>
+      <div role="row" aria-rowindex="2">
+          <span role="columnheader">Score</span>
+          <span role="columnheader">Grade</span>
+          <span role="columnheader">Score</span>
+          <span role="columnheader">Grade</span>
+          <span role="columnheader">Total</span>
+          <span role="columnheader">Grade</span>
+      </div>
+    </div>
+    <div role="rowgroup">
+      <div role="row" aria-rowindex="50">
+        <span role="cell">Henderson</span>
+        <span role="cell">Alan</span>
+        <span role="cell">89</span>
+        <span role="cell">B+</span>
+        <span role="cell">72</span>
+        <span role="cell">C</span>
+        <span role="cell">161</span>
+        <span role="cell">B-</span>
+      </div>
+      <div role="row" aria-rowindex="51">
+        <span role="cell">Henderson</span>
+        <span role="cell">Alice</span>
+        <span role="cell">94</span>
+        <span role="cell">A</span>
+        <span role="cell">86</span>
+        <span role="cell">B</span>
+        <span role="cell">180</span>
+        <span role="cell">A-</span>
+      </div>
+      <div role="row" aria-rowindex="52">
+        <span role="cell">Henderson</span>
+        <span role="cell">Andrew</span>
+        <span role="cell">82</span>
+        <span role="cell">B-</span>
+        <span role="cell">95</span>
+        <span role="cell">A</span>
+        <span role="cell">177</span>
+        <span role="cell">B+</span>
+      </div>
+    </div>
+  </div>
+
+
+

+ Note: When using HTML table elements, + use the native semantics of the th and td elements to define row and column spans + by using the rowspan and colspan attributes. +

+
+
+

Indicating sort order with aria-sort

+

+ When rows or columns are sorted, the aria-sort property can be applied to a column or row header to indicate the sorting method. + The following table describes allowed values for aria-sort. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Description of values for aria-sort +
ValueDescription
ascendingData are sorted in ascending order.
descendingData are sorted in descending order.
otherData are sorted by an algorithm other than ascending or descending.
noneDefault (no sort applied).
+

+ It is important to note that ARIA does not provide a way to indicate levels of sort for data sets that have multiple sort keys. + Thus, there is limited value to applying aria-sort with a value other than none to more than one column or row. +

+

The following example grid uses aria-sort to indicate the rows are sorted from the highest "Quiz 2" score to the lowest "Quiz 2" score.

+
+
+<table role="grid" aria-rowcount="463" aria-colcount="13"
+  aria-label="Student grades for history 101">
+  <thead>
+    <tr aria-colindex="10" aria-rowindex="1">
+      <th>Homework 4</th>
+      <!--
+        aria-sort indicates the column with the heading
+        "Quiz 2" has been used to sort the rows of the grid.
+      -->
+      <th aria-sort="descending">Quiz 2</th>
+      <th>Homework 5</th>
+      <th>Homework 6</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr aria-colindex="10" aria-rowindex="50">
+      <td>8</td>
+      <td>30</td>
+      <td>9</td>
+      <td>9</td>
+    </tr>
+    <tr aria-colindex="10"  aria-rowindex="51">
+      <td>10</td>
+      <td>29</td>
+      <td>10</td>
+      <td>8</td>
+    </tr>
+    <tr aria-colindex="10"  aria-rowindex="52">
+      <td>9</td>
+      <td>9</td>
+      <td>27</td>
+      <td>6</td>
+    </tr>
+    <tr aria-colindex="10"  aria-rowindex="53">
+      <td>9</td>
+      <td>10</td>
+      <td>26</td>
+      <td>8</td>
+    </tr>
+    <tr aria-colindex="10"  aria-rowindex="54">
+      <td>9</td>
+      <td>7</td>
+      <td>24</td>
+      <td>6</td>
+    </tr>
+  </tbody>
+</table>
+
+
+ +
+ + \ No newline at end of file diff --git a/content/practices/hiding-semantics/hiding-semantics-practice.html b/content/practices/hiding-semantics/hiding-semantics-practice.html new file mode 100644 index 0000000000..2715d8d339 --- /dev/null +++ b/content/practices/hiding-semantics/hiding-semantics-practice.html @@ -0,0 +1,168 @@ + + + + + +Hiding Semantics with the Presentation Role + + +

Hiding Semantics with the presentation Role

+
+

Introduction

+

+ While ARIA is primarily used to express semantics, there are some situations where hiding an element’s semantics from assistive technologies is helpful. + This is done with the + presentation + role, which declares that an element is being used only for presentation and therefore does not have any accessibility semantics. + The ARIA 1.1 specification also includes role + none, + which serves as a synonym for presentation. +

+

+ For example, consider a tabs widget built using an HTML ul element. +

+

+    <ul role="tablist">
+      <li role="presentation">
+        <a role="tab" href="#">Tab 1</a>
+      </li>
+      <li role="presentation">
+        <a role="tab" href="#">Tab 2</a>
+      </li>
+      <li role="presentation">
+        <a role="tab" href="#">Tab 3</a>
+      </li>
+    </ul>
+    
+

+ Because the list is declared to be a tablist, the list items are not in a list context. + It could confuse users if an assistive technology were to render those list items. + Applying role presentation to the li elements tells browsers to leave those elements out of their accessibility tree. + Assistive technologies will thus be unaware of the list item elements and see the tab elements as immediate children of the tablist. +

+
+ +
+

Common Uses of Role presentation

+

+ Three common uses of role presentation are: +

+
    +
  1. Hiding a decorative image; it is equivalent to giving the image null alt text.
  2. +
  3. Suppressing table semantics of tables used for layout in circumstances where the table semantics do not convey meaningful relationships.
  4. +
  5. Eliminating semantics of intervening orphan elements in the structure of a composite widget, such as a tablist, menu, or tree as demonstrated in the example above.
  6. +
+
+ +
+

Effects of Role presentation

+

+ When role="presentation" is specified on an element, if a + condition that requires a browser to ignore the presentation role + does not exist, it has the following three effects. +

+
    +
  1. + The element’s implied ARIA role and any ARIA states and properties associated with that role are hidden from assistive technologies. +
  2. +
  3. + Text contained by the element, i.e., inner text, as well as inner text of all its descendant elements remains visible to assistive technologies. + Of course, text is explicitly hidden, e.g., styled with display: none or has aria-hidden="true" is not visible to assistive technologies. +
  4. +
  5. + The roles, states, and properties of each descendant element remain visible to assistive technologies unless the descendant requires the context of the presentational element. + For example: +
      +
    • + If presentation is applied to a ul or ol element, each child li element inherits the presentation role because ARIA requires the listitem elements to have the parent list element. + So, the li elements are not exposed to assistive technologies, but elements contained inside of those li elements, including nested lists, are visible to assistive technologies. +
    • +
    • + Similarly, if presentation is applied to a table element, + the descendant caption, thead, tbody, tfoot, + tr, th, and td + elements inherit role presentation and are thus not exposed to assistive technologies. + But, elements inside of the th and td elements, including nested tables, are exposed to assistive technologies. +
    • +
    +
  6. +
+
+ +
+

Conditions That Cause Role presentation to be Ignored

+

Browsers ignore role="presentation", and it therefore has no effect, if either of the following are true about the element to which it is applied:

+ +
+ +
+

Example Demonstrating Effects of the presentation Role

+

In the following code, role presentation suppresses the list and list item semantics.

+

+    <ul role="presentation">
+      <li>Date of birth:</li>
+      <li>January 1, 3456</li>
+    </ul>
+    
+

When the above code is parsed by a browser, it is semantically equivalent to the following code:

+

+    <div>Date of birth:</div>
+    <div>January 1, 3456</div>
+    
+
+ +
+

Roles That Automatically Hide Semantics by Making Their Descendants Presentational

+

+ There are some types of user interface components that, when represented in a platform accessibility API, can only contain text. + For example, accessibility APIs do not have a way of representing semantic elements contained in a button. + To deal with this limitation, WAI-ARIA requires browsers to automatically apply role presentation to all descendant elements of any element with a role that cannot support semantic children. +

+

The roles that require all children to be presentational are:

+ +

For instance, consider the following tab element, which contains a heading.

+

+    <li role="tab"><h2>Title of My Tab</h2></li>
+    
+

+ Because WAI-ARIA requires descendants of tab to be presentational, the heading semantic is not exposed to assistive technology users. + Thus, the following code is equivalent. +

+

+    <li role="tab"><h2 role="presentation">Title of My Tab</h2></li>
+    
+

+ So, from the perspective of anyone using a technology that relies on an accessibility API, such as a screen reader, the heading does not exist. + As described above in the section on + Effects of Role presentation, + the previous code is equivalent to the following. +

+

+    <li role="tab">Title of My Tab</li>
+    
+
+ + + \ No newline at end of file diff --git a/content/practices/keyboard-interface/keyboard-interface-practice.html b/content/practices/keyboard-interface/keyboard-interface-practice.html new file mode 100644 index 0000000000..f24f2a5500 --- /dev/null +++ b/content/practices/keyboard-interface/keyboard-interface-practice.html @@ -0,0 +1,640 @@ + + + + + +Developing a Keyboard Interface + + +

Developing a Keyboard Interface

+
+

Introduction

+

+ Unlike native HTML form elements, browsers do not provide keyboard support for graphical user interface (GUI) components that are made accessible with ARIA; authors have to provide the keyboard support in their code. + This section describes the principles and methods for making the functionality of a web page that includes ARIA widgets, such as menus and grids, as well as interactive components, such as toolbars and dialogs, operable with a keyboard. + Along with the basics of focus management, this section offers guidance toward the objective of providing experiences to people who rely on a keyboard that are as efficient and enjoyable as the experiences available to others. +

+

This section covers:

+
    +
  1. Understanding fundamental principles of focus movement conventions used in ARIA design patterns.
  2. +
  3. Maintaining visible focus, predictable focus movement, and distinguishing between keyboard focus and the selected state.
  4. +
  5. Managing movement of keyboard focus between components, e.g., how the focus moves when the Tab and Shift+Tab keys are pressed.
  6. +
  7. Managing movement of keyboard focus inside components that contain multiple focusable elements, e.g., two different methods for programmatically exposing focus inside widgets like radio groups, menus, listboxes, trees, and grids.
  8. +
  9. Determining when to make disabled interactive elements focusable.
  10. +
  11. Assigning and revealing keyboard shortcuts, including guidance on how to avoid problematic conflicts with keyboard commands of assistive technologies, browsers, and operating systems.
  12. +
+
+
+

Fundamental Keyboard Navigation Conventions

+ +

+ ARIA roles, states, and properties model accessibility behaviors and features shared among GUI components of popular desktop GUIs, including Microsoft Windows, macOS, and GNOME. + Similarly, ARIA design patterns borrow user expectations and keyboard conventions from those platforms, consistently incorporating common conventions with the aim of facilitating easy learning and efficient operation of keyboard interfaces across the web. +

+ +

+ For a web page to be accessible, all interactive elements must be operable via the keyboard. + In addition, consistent application of the common GUI keyboard interface conventions described in the APG patterns is important, especially for assistive technology users. + Consider, for example, a screen reader user operating a tree. + Just as familiar visual styling helps users discover how to expand a tree branch with a mouse, ARIA attributes give the tree the sound and feel of a tree in a desktop application. + So, screen reader users will commonly expect that pressing the right arrow key will expand a collapsed node. + Because the screen reader knows the element is a tree, it also has the ability to instruct a novice user how to operate it. + Similarly, voice recognition software can implement commands for expanding and collapsing branches because it recognizes the element as a tree and can execute appropriate keyboard commands. + All this is only possible if the tree implements the GUI keyboard conventions as described in the Tree View Pattern. +

+ +

+ A primary keyboard navigation convention common across all platforms is that the tab and shift+tab keys move focus from one UI component to another while other keys, primarily the arrow keys, move focus inside of components that include multiple focusable elements. + The path that the focus follows when pressing the tab key is known as the tab sequence or tab ring. +

+ +

+ Common examples of UI components that contain multiple focusable elements are radio groups, tablists, menus, and grids. + A radio group, for example, contains multiple radio buttons, each of which is focusable. + However, only one of the radio buttons is included in the tab sequence. + After pressing the Tab key moves focus to a radio button in the group, pressing arrow keys moves focus among the radio buttons in the group, and pressing the Tab key moves focus out of the radio group to the next element in the tab sequence. +

+ +

+ The ARIA specification refers to a discrete UI component that contains multiple + focusable elements as a composite + widget. The process of controlling focus movement inside a composite is called + managing focus. Following are some ARIA design patterns with example implementations + that demonstrate focus management: +

+ + +
+ +
+

Discernible and Predictable Keyboard Focus

+

Work to complete this section is tracked by issue 217.

+

+ When operating with a keyboard, two essentials of a good experience are the abilities to easily discern the location of the keyboard focus and to discover where focus landed after a navigation key has been pressed. + The following factors affect to what extent a web page affords users these capabilities. +

+ +
    +
  1. Visibility of the focus indicator: Users need to be able to easily distinguish the keyboard focus indicator from other features of the visual design. Just as a mouse user may move the mouse to help find the mouse pointer, a keyboard user may press a navigation key to watch for movement. If visual changes in response to focus movement are subtle, many users will lose track of focus and be unable to operate. Authors are advised to rely on the default focus indicators provided by browsers. If overriding the default, consider: +
      +
    • something about ... Colors and gradients can disappear in high contrast modes.
    • +
    • Users need to be able to easily distinguish between focus and selection as described in Focus VS Selection and the Perception of Dual Focus, especially when a component that contains selected elements does not contain the focus.
    • +
    • ... other considerations to be added ...
    • +
    +
  2. + +
  3. Persistence of focus: It is essential that there is always a component within the user interface that is active (document.activeElement is not null or is not the body element) and that the active element has a visual focus indicator. Authors need to manage events that effect the currently active element so focus remains visible and moves logically. For example, if the user closes a dialog or performs a destructive operation like deleting an item from a list, the active element may be hidden or removed from the DOM. If such events are not managed to set focus on the button that triggered the dialog or on the list item following the deleted item, browsers move focus to the body element, effectively causing a loss of focus within the user interface.
  4. + +
  5. + Predictability of movement: Usability of a keyboard interface is heavily influenced by how readily users can guess where focus will land after a navigation key is pressed. + Some possible approaches to optimizing predictability include: + +
      +
    • + Move focus in a pattern that matches the reading order of the page's language. In left to right languages, for example, create a tab sequence that moves focus left to right and then top to bottom. +
    • + +
    • + Incorporate all elements of a section of the page in the tab sequence before moving focus to another section. For instance, in a page + with multiple columns that has content in a left side bar, center region, and right side bar, build a tab sequence that covers all elements in the left sidebar before focus moves to the first focusable element in the center column. +
    • + +
    • + When the distance between two consecutive elements in the tab sequence is significant, avoid movement that would be perceived as backward. + For example, on a page with a left to right language, a jump from the last element in the bottom right of the main content to the top element in a left-hand sidebar is likely to be less predictable and more difficult to follow, especially for users with a narrow field of view. +
    • + +
    • + Follow consistent patterns across a site. + The keyboard experience is more predictable when similar pages have similar focus movement patterns. +
    • + +
    • Do not set initial focus when the page loads except in cases where: +
        +
      • The page offers a single, primary function that nearly all users employ immediately after page load.
      • +
      • Any given user is likely to use the page often.
      • +
      +
    • +
    +
  6. +
+
+ +
+

Focus VS Selection and the Perception of Dual Focus

+ +

+ Occasionally, it may appear as if two elements on the page have focus at the same time. + For example, in a multi-select list box, when an option is selected it may be greyed. + Yet, the focus indicator can still be moved to other options, which may also be selected. + Similarly, when a user activates a tab in a tablist, the selected state is set on the tab and its visual appearance changes. + However, the user can still navigate, moving the focus indicator elsewhere on the page while the tab retains its selected appearance and state. +

+ +

+ Focus and selection are quite different. + From the keyboard user's perspective, focus is a pointer, like a mouse pointer; it tracks the path of navigation. + There is only one point of focus at any time and all operations take place at the point of focus. + On the other hand, selection is an operation that can be performed in some widgets, such as list boxes, trees, and tablists. + If a widget supports only single selection, then only one item can be selected and very often the selected state will simply follow the focus when focus is moved inside of the widget. + That is, in some widgets, moving focus may also perform the select operation. + However, if the widget supports multiple selection, then more than one item can be in a selected state, and keys for moving focus do not perform selection. + Some multi-select widgets do support key commands that both move focus and change selection, but those keys are different from the normal navigation keys. + Finally, when focus leaves a widget that includes a selected element, the selected state persists. +

+ +

+ From the developer's perspective, the difference is simple -- the focused element is the active element (document.activeElement). + Selected elements are elements that have aria-selected="true". +

+ +

With respect to focus and the selected state, the most important considerations for designers and developers are:

+ + +
+ +
+

Deciding When to Make Selection Automatically Follow Focus

+

in composite widgets where only one element may be selected, such as a tablist or single-select listbox, moving the focus may also cause the focused element to become the selected element. This is called having selection follow focus. Having selection follow focus is often beneficial to users, but in some circumstances, it is extremely detrimental to accessibility.

+

+ For example, in a tablist, the selected state is used to indicate which panel is displayed. + So, when selection follows focus in a tablist, moving focus from one tab to another automatically changes which panel is displayed. + If the content of panels is present in the DOM, then displaying a new panel is nearly instantaneous. + A keyboard user who wishes to display the fourth of six tabs can do so with 3 quick presses of the right arrow. + And, a screen reader user who perceives the labels on tabs by navigating through them may efficiently read through the complete list without any latency. +

+

However, if displaying a new panel causes a network request and possibly a page refresh, the effect of having selection automatically focus can be devastating to the experience for keyboard and screen reader users. In this case, displaying the fourth tab or reading through the list becomes a tedious and time-consuming task as the user experiences significant latency with each movement of focus. Further, if displaying a new tab refreshes the page, then the user not only has to wait for the new page to load but also return focus to the tab list.

+

+ When selection does not follow focus, the user changes which element is selected by pressing the Enter or Space key. +

+
+ +
+

Keyboard Navigation Between Components (The Tab Sequence)

+ +

As explained in section Fundamental Keyboard Navigation Conventions, all interactive UI components need to be reachable via the keyboard. This is best achieved by either including them in the tab sequence or by making them accessible from a component that is in the tab sequence, e.g., as part of a composite component. This section addresses building and managing the tab sequence, and subsequent sections cover making focusable elements that are contained within components keyboard accessible.

+ +

+ The HTML tabindex and SVG2 tabindex attributes can be used to add and remove elements from the tab sequence. + The value of tabindex can also influence the order of the tab sequence, although authors are strongly advised not to use tabindex for that purpose. +

+ +

+ In HTML, the default tab sequence of a web page includes only links and HTML form elements, except In macOS, where it includes only form elements. + macOS system preferences include a keyboard setting that enables the tab key to move focus to all focusable elements. +

+ +

+ The default order of elements in the tab sequence is the order of elements in the DOM. + The DOM order also determines screen reader reading order. + It is important to keep the keyboard tab sequence and the screen reader reading order aligned, logical, and predictable as described in Discernible and Predictable Keyboard Focus. + The most robust method of manipulating the order of the tab sequence while also maintaining alignment with the reading order that is currently available in all browsers is rearranging elements in the DOM. +

+ +

The values of the tabindex attribute have the following effects.

+ +
+
tabindex is not present or does not have a valid value
+
+ The element has its default focus behavior. + In HTML, only form controls and anchors with an HREF attribute are included in the tab sequence. +
+
tabindex="0"
+
The element is included in the tab sequence based on its position in the DOM.
+
tabindex="-1"
+
The element is not included in the tab sequence but is focusable with element.focus().
+
tabindex="X" where X is an integer in the range 1 <= X <= 32767
+
+ Authors are strongly advised NOT to use these values. + The element is placed in the tab sequence based on the value of tabindex. + Elements with a tabindex value of 0 and elements that are focusable by default will be in the sequence after elements with a tabindex value of 1 or greater. +
+
+
+ +
+

Keyboard Navigation Inside Components

+ +

+ As described in section Fundamental Keyboard Navigation Conventions, the tab sequence should include only one focusable element of a composite UI component. + Once a composite contains focus, keys other than Tab and Shift + Tab enable the user to move focus among its focusable elements. + Authors are free to choose which keys move focus inside of a composite, but they are strongly advised to use the same key bindings as similar components in common GUI operating systems as demonstrated in APG Patterns. +

+ +

The convention for where focus lands in a composite when it receives focus as a result of a Tab key event depends on the type of composite. It is typically one of the following.

+ + + +

+ The following sections explain two strategies for managing focus inside composite elements: creating a roving tabindex and using the aria-activedescendant property. +

+ +
+

Managing Focus Within Components Using a Roving tabindex

+ +

+ When using roving tabindex to manage focus in a composite UI component, the element that is to be included in the tab sequence has tabindex of "0" and all other focusable elements contained in the composite have tabindex of "-1". + The algorithm for the roving tabindex strategy is as follows. +

+ +
    +
  • When the component container is loaded or created, set tabindex="0" on the element that will initially be included in the tab sequence and set tabindex="-1" on all other focusable elements it contains.
  • +
  • + When the component contains focus and the user presses a navigation key that moves focus within the component, such as an arrow key: + +
      +
    • set tabindex="-1" on the element that has tabindex="0".
    • +
    • Set tabindex="0" on the element that will become focused as a result of the key event.
    • +
    • Set focus, element.focus(), on the element that has tabindex="0".
    • +
    +
  • + +
  • + If the design calls for a specific element to be focused the next time the user moves focus into the composite with Tab or Shift+Tab, check if that target element has tabindex="0" when the composite loses focus. + If it does not, set tabindex="0" on the target element and set tabindex="-1" on the element that previously had tabindex="0". +
  • +
+ +

+ One benefit of using roving tabindex rather than aria-activedescendant to manage focus is that the user agent will scroll the newly focused element into view. +

+
+ +
+

Managing Focus in Composites Using aria-activedescendant

+ +

+ If a component container has an ARIA role that supports the aria-activedescendant property, it is not necessary to manipulate the tabindex attribute and move DOM focus among focusable elements within the container. + Instead, only the container element needs to be included in the tab sequence. When the container has DOM focus, the value of aria-activedescendant on the container tells assistive technologies which element is active within the widget. + Assistive technologies will consider the element referred to as active to be the focused element even though DOM focus is on the element that has the aria-activedescendant property. + And, when the value of aria-activedescendant is changed, assistive technologies will receive focus change events equivalent to those received when DOM focus actually moves. +

+ +

The steps for using the aria-activedescendant method of managing focus are as follows.

+ +
    +
  • When the container element that has a role that supports aria-activedescendant is loaded or created, ensure that: +
      +
    • The container element is included in the tab sequence as described in Keyboard Navigation Between Components or is a focusable element of a composite that implements a roving tabindex.
    • +
    • + It has aria-activedescendant="IDREF" where IDREF is the ID of the element within the container that should be identified as active when the widget receives focus. + The referenced element needs to meet the DOM relationship requirements described below. +
    • +
    +
  • +
  • When the container element receives DOM focus, draw a visual focus indicator on the active element and ensure the active element is scrolled into view.
  • +
  • When the composite widget contains focus and the user presses a navigation key that moves focus within the widget, such as an arrow key: +
      +
    • Change the value of aria-activedescendant on the container to refer to the element that should be reported to assistive technologies as active.
    • +
    • Move the visual focus indicator and, if necessary, scrolled the active element into view.
    • +
    +
  • +
  • + If the design calls for a specific element to be focused the next time a user moves focus into the composite with Tab or Shift+Tab, check if aria-activedescendant is referring to that target element when the container loses focus. + If it is not, set aria-activedescendant to refer to the target element. +
  • +
+ +

+ The specification for aria-activedescendant places important restrictions on the DOM relationship between the focused element that has the aria-activedescendant attribute and the element referenced as active by the value of the attribute. + One of the following three conditions must be met. +

+
    +
  1. The element referenced as active is a DOM descendant of the focused referencing element.
  2. +
  3. The focused referencing element has a value specified for the aria-owns property that includes the ID of the element referenced as active.
  4. +
  5. The focused referencing element has role of combobox, textbox, or searchbox and has aria-controls property referring to an element with a role that supports aria-activedescendant and either: +
      +
    1. The element referenced as active is a descendant of the controlled element.
    2. +
    3. The controlled element has a value specified for the aria-owns property that includes the ID of the element referenced as active.
    4. +
    +
  6. +
+
+
+
+

Focusability of disabled controls

+

+ By default, disabled HTML input elements are removed from the tab sequence. + In most contexts, the normal expectation is that disabled interactive elements are not focusable. + However, there are some contexts where it is common for disabled elements to be focusable, especially inside of composite widgets. + For example, as demonstrated in the menu and menubar pattern, disabled items are focusable when navigating through a menu with the arrow keys. +

+ +

+ Removing focusability from disabled elements can offer users both advantages and disadvantages. + Allowing keyboard users to skip disabled elements usually reduces the number of key presses required to complete a task. + However, preventing focus from moving to disabled elements can hide their presence from screen reader users who "see" by moving the focus. +

+ +

+ Authors are encouraged to adopt a consistent set of conventions for the focusability of disabled elements. + The examples in this guide adopt the following conventions, which both reflect common practice and attempt to balance competing concerns. +

+ +
    +
  1. For elements that are in the tab sequence when enabled, remove them from the tab sequence when disabled.
  2. + +
  3. + For the following composite widget elements, keep them focusable when disabled: + + +
  4. + +
  5. + For elements contained in a toolbar, make them focusable if discoverability is a concern. Here are two examples to aid with this judgment. + +
      +
    1. + A toolbar with buttons for moving, removing, and adding items in a list includes buttons for "Up", "Down", "Add", and "Remove". + The "Up" button is disabled and its focusability is removed when the first item in the list is selected. + Given the presence of the "Down" button, discoverability of the "Up" button is not a concern. +
    2. + +
    3. + A toolbar in an editor contains a set of special smart paste functions that are disabled when the clipboard is empty or when the function is not applicable to the current content of the clipboard. + It could be helpful to keep the disabled buttons focusable if the ability to discover their functionality is primarily via their presence on the toolbar. +
    4. +
    +
  6. +
+ +

One design technique for mitigating the impact of including disabled elements in the path of keyboard focus is employing appropriate keyboard shortcuts as described in Keyboard Shortcuts.

+
+
+

Key Assignment Conventions for Common Functions

+

+ The following key assignments can be used in any context where their conventionally associated functions are appropriate. + While the assignments associated with Windows and Linux platforms can be implemented and used in browsers running in macOS, + replacing them with macOS assignments in browsers running on a macOS device can make the keyboard interface more discoverable and intuitive for those users. + In some cases, it may also help avoid system or browser keyboard conflicts. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionWindows/Linux KeymacOS Key
open context menuShift + F10
Copy to clipboardControl + CCommand + C
Paste from clipboardControl + VCommand + V
Cut to clipboardControl + XCommand + X
undo last actionControl + ZCommand + Z
Redo actionControl + YCommand + Shift + Z
+
+
+

Keyboard Shortcuts

+

+ When effectively designed, keyboard shortcuts that focus an element, activate a widget, or both can dramatically enhance usability of frequently used features of a page or site. + This section addresses some of the keyboard shortcut design and implementation factors that most impact their effectiveness, including: +

+
    +
  1. Understanding how keyboard shortcuts augment a keyboard interface and whether to make a particular shortcut move focus, perform a function, or both.
  2. +
  3. Making key assignments and avoiding assignment conflicts with assistive technologies, browsers, and operating systems.
  4. +
  5. Exposing and documenting key assignments.
  6. +
+
+

Designing the Scope and Behavior of Keyboard Shortcuts

+ +

This section explains the following factors when determining which elements and features to assign keyboard shortcuts and what behavior to give each shortcut:

+ +
    +
  1. Ensuring discovery through navigation; keyboard shortcuts enhance, not replace, standard keyboard access.
  2. + +
  3. + Effectively choosing from among the following behaviors: + +
      +
    1. Navigation: Moving focus to an element.
    2. +
    3. Activation: Performing an operation associated with an element that does not have focus and might not be visible.
    4. +
    5. Navigation and activation: Both moving focus to an element and activating it.
    6. +
    +
  4. + +
  5. Balancing efficiency and cognitive load: lack of a shortcut can reduce efficiency while too many shortcuts can increase cognitive load and clutter the experience.
  6. +
+ +
+

Ensure Basic Access Via Navigation

+ +

+ Before assigning keyboard shortcuts, it is essential to ensure the features and functions to which shortcuts may be assigned are keyboard accessible without a keyboard shortcut. + In other words, all elements that could be targets for keyboard shortcuts need to be focusable via the keyboard using the methods described in: +

+ + + +

+ Do not use keyboard shortcuts as a substitute for access via navigation. + This is essential to full keyboard access because: +

+ +
    +
  1. The primary means of making functions and their shortcuts discoverable is by making the target elements focusable and revealing key assignments on the element itself.
  2. +
  3. If people who rely on the keyboard have to read documentation to learn which keys are required to use an interface, the interface may technically meet some accessibility standards but in practice is only accessible to the small subset of them who have the knowledge that such documentation exists, have the extra time available, and the ability to retain the necessary information.
  4. +
  5. Not all devices that depend on keyboard interfaces can support keyboard shortcuts.
  6. +
+
+ +
+

Choose Appropriate Shortcut Behavior

+ +

The following conventions may help identify the most advantageous behavior for a keyboard shortcut.

+ +
    +
  • + Move focus when the primary objective is to make navigation more efficient, e.g., reduce the number of times the user must press Tab or the arrow keys. + This behavior is commonly expected when assigning a shortcut to a text box, toolbar, or composite, such as a listbox, tree, grid, or menubar. + This behavior is also useful for moving focus to a section of a page, such as the main content or a complementary landmark section. +
  • + +
  • Activate an element without moving focus when the target context of the function is the context that contains the focus. This behavior is most common for command buttons and for functions associated with elements that are not visible, such as a "Save" option that is accessible via a menu. For example, if the focus is on an option in a listbox and a toolbar contains buttons for moving and removing options, it is most beneficial to keep focus in the listbox when the user presses a key shortcut for one of the buttons in the toolbar. This behavior can be particularly important for screen reader users because it provides confirmation of the action performed and makes performing multiple commands more efficient. For instance, when a screen reader user presses the shortcut for the "Up" button, the user will be able to hear the new position of the option in the list since it still has the focus. Similarly, when the user presses the shortcut for deleting an option, the user can + hear the next option in the list and immediately decide whether to press the delete shortcut again.
  • + +
  • + Move focus and activate when the target of the shortcut has a single function and the context of that function is the same as the target. + This behavior is typical when a shortcut is assigned to a button that opens a menu or dialog, to a checkbox, or to a navigation link or button. +
  • +
+
+ +
+

Choose Where to Add Shortcuts

+

Work to draft content for this section is tracked in issue 219.

+

The first goal when designing a keyboard interface is simple, efficient, and intuitive operation with only basic keyboard navigation support. If basic operation of a keyboard interface is inefficient, attempting to compensate for fundamental design issues, such as suboptimal layout or command structure, by implementing keyboard shortcuts will not likely reduce user frustration. The practical implication of this is that, in most well-designed user interfaces, the percentage of functionality that needs to be accessible via a keyboard shortcut in order to create optimal usability is not very high. In many simple user interfaces, keyboard shortcuts can be entirely superfluous. And, in user interfaces with too many keyboard shortcuts, the excess shortcuts create cognitive load that make the most useful ones more difficult to remember.

+

Consider the following when deciding where to assign keyboard shortcuts:

+ +
    +
  1. To be written.
  2. +
+
+
+
+

Assigning Keyboard Shortcuts

+

When choosing the keys to assign to a shortcut, there are many factors to consider.

+
    +
  • Making the shortcut easy to learn and remember by using a mnemonic (e.g., Control + S for "Save") or following a logical or spacial pattern.
  • +
  • Localizing the interface, including for differences in which keys are available and how they behave and for language considerations that could impact mnemonics.
  • +
  • Avoiding and managing conflicts with key assignments used by an assistive technology, the browser, or the operating system.
  • +
+

+ Methods for designing a key shortcut scheme that supports learning and memory is beyond the scope of this guide. + Unless the key shortcut scheme is extensive, it is likely sufficient to mimic concepts that are familiar from common desktop software, such as browsers. + Similarly, while localization is important, describing how to address it is left to other resources that specialize in that topic. +

+

+ The remainder of this section provides guidance balancing requirements and concerns related to key assignment conflicts. + It is typically ideal if key assignments do not conflict with keys that are assigned to functions in the user's operating system, browser, or assistive technology. + Conflicts can block efficient access to functions that are essential to the user, and a perfect storm of conflicts can trap a user. + At the same time, there are some circumstances where intentional conflicts are useful. + And, given the vast array of operating system, browser, and assistive technology keys, it is almost impossible to be certain conflicts do not exist. + So it is also important to employ strategies that mitigate the impact of conflicts whether they are intentional or unknown. +

+

+ In the following sections, meta key refers to the Windows key on Windows-compatible keyboards and the Command key on MacOS-compatible keyboards. +

+
+

Operating System Key Conflicts

+ +

It is essential to avoid conflicts with keys that perform system level functions, such as application and window management and display and sound control. In general, this can be achieved by refraining from the following types of assignments.

+ +
    +
  1. Any modifier keys + any of Tab, Enter, Space, or Escape.
  2. + +
  3. Meta key + any other single key (there are exceptions, but they can be risky as these keys can change across versions of operating systems).
  4. + +
  5. Alt + a function key.
  6. +
+ +

+ In addition, there are some important application level features that most applications, including browsers, generally support. + These include: +

+ +
    +
  1. Zoom
  2. +
  3. Copy/Paste
  4. +
  5. ... to be continued ...
  6. +
+
+ +
+

Assistive Technology Key Conflicts

+ +

+ Even though assistive technologies have collectively taken thousands of key assignments, avoiding conflicts is relatively easy. + This is because assistive technologies have had to develop key assignment schemes that avoid conflicts with both operating systems and applications. + They do this by hijacking specific keys as modifiers that uniquely define their key commands. + For example, many assistive technologies use the Caps Lock key as a modifier. +

+ +

Deflect assistive technology key conflicts by steering clear of the following types of assignments.

+ +
    +
  1. Caps Lock + any other combination of keys.
  2. +
  3. Insert + any combination of other keys.
  4. +
  5. Scroll Lock + any combination of other keys.
  6. +
  7. macOS only: Control+Option + any combination of other keys.
  8. +
+
+ +
+

Browser Key Conflicts

+ +

While there is considerable similarity among browser keyboard schemes, the patterns within the schemes are less homogenous. Consequently, it is more difficult to avoid conflicts with browser key assignments. While the impact of conflicts is sometimes mitigated by the availability of two paths to nearly every function -- keyboard accessible menus and keyboard shortcuts, avoiding conflicts with shortcuts to heavily used functions is nonetheless important. Pay special attention to avoiding conflicts with shortcuts to:

+ +
    +
  1. Address or location bar
  2. +
  3. Notification bar
  4. +
  5. Page refresh
  6. +
  7. Bookmark and history functions
  8. +
  9. Find functions
  10. +
+
+
+

Intentional Key Conflicts

+ +

+ While avoiding key conflicts is usually desirable, there are circumstances where intentionally conflicting with a browser function is acceptable or even desirable. + This can occur when the following combination of conditions arises: +

+ +
    +
  • A web application has a frequently used function that is similar to a browser function.
  • +
  • Users will often want to execute the web application function.
  • +
  • Users will rarely execute the browser function.
  • +
  • There is an efficient, alternative path to the browser function.
  • +
+ +

For example, consider a save function that is available when the focus is in an editor. Most browsers use ... to be continued ...

+
+
+
+ + \ No newline at end of file diff --git a/content/practices/landmark-regions/landmark-regions-practice.html b/content/practices/landmark-regions/landmark-regions-practice.html new file mode 100644 index 0000000000..79e85e54e5 --- /dev/null +++ b/content/practices/landmark-regions/landmark-regions-practice.html @@ -0,0 +1,430 @@ + + + + + +Landmark Regions + + +

Landmark Regions

+
+

Introduction

+

+ ARIA landmark roles provide a powerful way to identify the organization and structure of a web page. + By classifying and labelling sections of a page, they enable structural information that is conveyed visually through layout to be represented programmatically. + Screen readers exploit landmark roles to provide keyboard navigation to important sections of a page. + Landmark regions can also be used as targets for "skip links" and by browser extensions to enhanced keyboard navigation. +

+

+ This section explains how HTML sectioning elements and ARIA landmark roles + are used to make it easy for assistive technology users to understand the meaning of the layout of a page. +

+
+ +
+

HTML Sectioning Elements

+

+ Several HTML sectioning elements automatically create ARIA landmark regions. + So, in order to provide assistive technology users with a logical view of a page, + it is important to understand the effects of using HTML sectioning elements. + [[HTML-ARIA]] contains more information on HTML element role mapping. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Default landmark roles for HTML sectioning elements
HTML ElementDefault Landmark Role
asidecomplementary
footercontentinfo when in context of the body element
headerbanner when in context of the body element
mainmain
navnavigation
sectionregion when it has an accessible name using aria-labelledby or aria-label
+
+ +
+

General Principles of Landmark Design

+

+ Including all perceivable content on a page in one of its landmark regions + and giving each landmark region a semantically meaningful role + is one of the most effective ways of ensuring assistive technology users will not overlook information that is relevant to their needs. +

+

Step 1: Identify the logical structure

+ + + +

Step 2: Assign landmark roles to each area

+ + + +

Step 3: Label areas

+ + +
+ +
+

Landmark Roles

+ +
+

Banner

+ +

+ A banner landmark identifies site-oriented content at the beginning of each page within a website. Site-oriented content typically includes things such as the logo or identity + of the site sponsor, and site-specific search tool. A banner usually appears at the top of the page and typically spans the full width. +

+ +
    +
  • Each page may have one banner landmark.
  • + +
  • The banner landmark should be a top-level landmark.
  • + +
  • When a page contains nested document and/or application roles (e.g. typically through the use of iframe and frame elements), each document or application role may have + one banner landmark.
  • + +
  • If a page includes more than one banner landmark, each should have a unique label (see Step 3 above).
  • +
+ +
+

HTML Techniques

+
    +
  • The HTML header element defines a banner landmark when its context is the body element.
  • + +
  • + The HTML header element is not considered a banner landmark when it is descendant of any of following elements (see HTML Accessibility Mappings): +
      +
    • article
    • +
    • aside
    • +
    • main
    • +
    • nav
    • +
    • section
    • +
    +
  • +
+ +

ARIA Techniques

+ +

If the HTML header element technique is not being used, a role="banner" attribute should be used to define a banner landmark.

+
+ +
+

Examples

+ +

Banner Landmark Example

+
+ +
+ +
+

Complementary

+ +

A complementary landmark is a supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful + when separated from the main content.

+ +
    +
  • complementary landmarks should be top level landmarks (e.g. not contained within any other landmarks).
  • + +
  • If the complementary content is not related to the main content, a more general role should be assigned (e.g. region).
  • + +
  • If a page includes more than one complementary landmark, each should have a unique label (see Step 3 above).
  • +
+ +
+

HTML Technique

+ +

Use the HTML aside element to define a complementary landmark.

+ +

ARIA Technique

+ +

If the HTML aside element technique is not being used, use a role="complementary" attribute to define a complementary landmark.

+
+ +
+

Examples

+ +

Complementary Landmark Example

+
+
+ +
+

Contentinfo

+ +

A contentinfo landmark is a way to identify common information at the bottom of each page within a website, typically called the "footer" of the page, including information + such as copyrights and links to privacy and accessibility statements.

+ +
    +
  • Each page may have one contentinfo landmark.
  • + +
  • The contentinfo landmark should be a top-level landmark.
  • + +
  • When a page contains nested document and/or application roles (e.g. typically through the use of iframe and frame elements), each document or application role may have + one contentinfo landmark.
  • + +
  • If a page includes more than one contentinfo landmark, each should have a unique label (see Step 3 above).
  • +
+ +
+ +

HTML Techniques

+ +
    +
  • The HTML footer element defines a contentinfo landmark when its context is the body element.
  • + +
  • + The HTML footer element is not considered a contentinfo landmark when it is descendant of any of following elements (see HTML Accessibility Mappings): +
      +
    • article
    • +
    • aside
    • +
    • main
    • +
    • nav
    • +
    • section
    • +
    +
  • +
+ +

ARIA Technique

+ +

If the HTML footer element technique is not being used, a role="contentinfo" attribute should be used to define a contentinfo landmark.

+
+ +
+

Examples

+

Contentinfo Landmark Example

+
+
+ +
+

Form

+ +

A form landmark identifies a region that contains a collection of items and objects that, as a whole, combine to create a form when no other named landmark is appropriate (e.g. main + or search).

+ +
    +
  • Use the search landmark instead of the form landmark when the form is used for search functionality.
  • + +
  • A form landmark should have a label to help users understand the purpose of the form.
  • + +
  • A label for the form landmark should be visible to all users (e.g. an h1-h6 element).
  • + +
  • If a page includes more than one form landmark, each should have a unique label (see Step 3 above).
  • + +
  • + Whenever possible, controls contained in a form landmark in an HTML document should use native host semantics: +
      +
    • button
    • + +
    • input
    • + +
    • select
    • + +
    • textarea
    • +
    +
  • +
+ +
+

HTML Techniques

+ +

The HTML form element defines a form landmark when it has an accessible name (e.g. aria-labelledby, aria-label or title).

+ +

ARIA Technique

+ +

Use the role="form" to identify a region of the page; do not use it to identify every form field.

+
+ +
+

Examples

+ +

Form Landmark Example

+
+
+ +
+

Main

+ +

A main landmark identifies the primary content of the page.

+ +
    +
  • Each page should have one main landmark.
  • + +
  • The main landmark should be a top-level landmark.
  • + +
  • When a page contains nested document and/or application roles (e.g. typically through the use of iframe and frame elements), each document or application role may have + one main landmark.
  • + +
  • If a page includes more than one main landmark, each should have a unique label (see Step 3 above).
  • +
+ +
+

HTML Technique

+ +

Use the HTML main element to define a main landmark.

+ +

ARIA Technique

+ +

If the HTML main element technique is not being used, use a role="main" attribute to define a main landmark.

+
+ +
+

Examples

+ +

Main Landmark Example

+
+
+ +
+

Navigation

+ +

Navigation landmarks provide a way to identify groups (e.g. lists) of links that are intended to be used for website or page content navigation.

+ +
    +
  • If a page includes more than one navigation landmark, each should have a unique label (see Step 3 above).
  • + +
  • If a navigation landmark has an identical set of links as another navigation landmark on the page, use the same label for each navigation landmark.
  • +
+ +
+

HTML Technique

+ +

Use the HTML nav element to define a navigation landmark.

+ +

ARIA Technique

+ +

If the HTML nav element technique is not being used, use a role="navigation" attribute to define a navigation landmark.

+ +
+ +
+

Examples

+ +

Navigation Landmark Example

+
+
+ +
+

Region

+ +

A region landmark is a perceivable section of the page containing content that is sufficiently important for users to be able to navigate to the section.

+ +
    +
  • A region landmark must have a label.
  • + +
  • If a page includes more than one region landmark, each should have a unique label (see Step 3 above).
  • + +
  • The region landmark can be used identify content that named landmarks do not appropriately describe.
  • +
+ +
+

HTML Technique

+ +

The HTML section element defines a region landmark when it has an accessible name (e.g. aria-labelledby, aria-label or title).

+ +

ARIA Technique

+ +

If the HTML section element technique is not being used, use a role="region" attribute to define a region landmark.

+
+ +
+

Examples

+ +

Region Landmark Example

+
+
+ + +
+ + + \ No newline at end of file diff --git a/content/practices/names-and-descriptions/names-and-descriptions-practice.html b/content/practices/names-and-descriptions/names-and-descriptions-practice.html new file mode 100644 index 0000000000..bd556bed04 --- /dev/null +++ b/content/practices/names-and-descriptions/names-and-descriptions-practice.html @@ -0,0 +1,1597 @@ + + + + + +Providing Accessible Names and Descriptions + + +

Providing Accessible Names and Descriptions

+
+

Introduction

+

+ Providing elements with accessible names, and where appropriate, accessible descriptions is one of the most important responsibilities authors have when developing accessible web experiences. + While doing so is straightforward for most elements, technical mistakes that can completely block users of assistive technologies are easy to make and unfortunately common. + To help authors effectively provide accessible names and descriptions, this section explains their purpose, when authors need to provide them, how browsers assemble them, and rules for coding and composing them. + It also guides authors in the use of the following naming and describing techniques and WAI-ARIA properties: +

+ +
+ +
+

What ARE Accessible Names and Descriptions?

+

+ An accessible name is a short string, typically 1 to 3 words, that authors associate with an element to provide users of assistive technologies with a label for the element. + For example, an input field might have an accessible name of "User ID" or a button might be named "Submit". +

+

An accessible name serves two primary purposes for users of assistive technologies, such as screen readers:

+
    +
  1. Convey the purpose or intent of the element.
  2. +
  3. Distinguish the element from other elements on the page.
  4. +
+

+ Both the WAI-ARIA specification and WCAG require all focusable, interactive elements to have an accessible name. + In addition dialogs and some structural containers, such as tables and regions, are required to have a name. + Many other elements can be named, but whether a name will enhance the accessible experience is determined by various characteristics of the surrounding context. + Finally, there are some elements where providing an accessible name is technically possible but not advisable. + The Accessible Name Guidance by Role section lists naming requirements and guidelines for every ARIA role. +

+

+ An accessible description is also an author-provided string that is rendered by assistive technologies. + Authors supply a description when there is a need to associate additional information with an element, such as instructions or format requirements for an input field. +

+

+ Assistive technologies present names differently from descriptions. + For instance, screen readers typically announce the name and role of an element first, e.g., a button named Mute Conversationcould be spoken as Mute Conversation button. + If an element has a state, it could be announced either before or after the name and role; after name and role is the typical default. + For example, a switch button named Mute Conversation in the off state could be announced as Mute Conversation switch button off. + Because descriptions are optional strings that are usually significantly longer than names, they are presented last, sometimes after a slight delay. + For example, Mute Conversation Switch button off, Silences alerts and notifications about activity in this conversation. + To reduce verbosity, some screen readers do not announce descriptions by default but instead inform users of their presence so that users can press a key that will announce the description. +

+
+ +
+

How Are Name and Description Strings Derived?

+

+ Because there are several elements and attributes for specifying text to include in an accessible name or description string, and because authors can combine them in a practically endless number of ways, browsers implement fairly complex algorithms for assembling the strings. + The sections on accessible name calculation and accessible description calculation explain the algorithms and how they implement precedence. + However, most authors do not need such detailed understanding of the algorithms since nearly all circumstances where a name or description is useful are supported by the coding patterns described in the naming techniques and describing techniques sections. +

+
+ +
+

Cardinal Rules of Naming

+ +
+

Rule 1: Heed Warnings and Test Thoroughly

+

+ Several of the naming techniques below include notes that warn against specific coding patterns that are either prohibited by the ARIA specification or fall into gray space that is not yet fully specified. + Some of these prohibited or ambiguous patterns may appear logical and even yield desired names in some browsers. + However, it is unlikely they will provide consistent results across browsers, especially over time as work to improve the consistency of name calculation across browsers progresses. +

+

+ In addition to heeding the warnings provided in the naming techniques, it is difficult to over emphasize the importance of testing to ensure that names browsers calculate match expectations. +

+
+ +
+

Rule 2: Prefer Visible Text

+

+ When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements. + When names are generated from text that exists only in markup and is never displayed visually, there is a greater likelihood that accessible names will not be updated when the user interface design or content are changed. +

+

+ If an interactive element, such as an input field or button, does not have a visually persistent text label, consider adjusting the design to include one. + In addition to serving as a more robust source for an accessible name, visible text labels enhance accessibility for many people with disabilities who do not use assistive technologies that present invisible accessible names. + In most circumstances, visible text labels also make the user interface easier to understand for all users. +

+
+ +
+

Rule 3: Prefer Native Techniques

+

+ In HTML documents, whenever possible, rely on HTML naming techniques, such as the HTML label element for form elements and caption element for tables. + While less flexible, their simplicity and reliance on visible text help ensure robust accessible experiences. + Several of the naming techniques highlight specific accessibility advantages of using HTML features instead of ARIA attributes. +

+
+ +
+

Rule 4: Avoid Browser Fallback

+

+ When authors do not specify an accessible name using an element or attribute that is intended for naming, browsers attempt to help assistive technology users by resorting to fallback methods for generating a name. + For example, the HTML title and placeholder attributes are used as last resort sources of content for accessible names. + Because the purpose of these attributes is not naming, their content typically yields low quality accessible names that are not effective. +

+
+ +
+

Rule 5: Compose Brief, Useful Names

+

+ Similar to how visually crowded screens and ambiguous icons reduce usability, excessively long, insufficiently distinct, or unclear accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface. + In other words, for a web experience to be accessible, its accessible names must be effective. + The section on Composing Effective and User-friendly Accessible Names provides guidance for balancing brevity and clarity. +

+
+
+ +
+

Naming Techniques

+ +
+

Naming with Child Content

+

+ Certain elements get their name from the content they contain. + For example, the following link is named "Home". +

+ +
<a href="/">Home</a>
+ +

+ When assistive technologies render an element that gets its accessible name from its content, such as a link or button, the accessible name is the only content the user can perceive for that element. + This is in contrast to other elements, such as text fields or tables, where the accessible name is a label that is presented in addition to the value or content of the element. + For instance, the accessible name of a table can be derived from a caption element, and assistive technologies render both the caption and all other content contained inside the table. +

+

Elements having one of the following roles are, by default, named by a string calculated from their descendant content:

+
    +
  • button
  • +
  • cell
  • +
  • checkbox
  • +
  • columnheader
  • +
  • gridcell
  • +
  • heading
  • +
  • link
  • +
  • menuitem (content contained in a child menu element is excluded.)
  • +
  • menuitemcheckbox
  • +
  • menuitemradio
  • +
  • option
  • +
  • radio
  • +
  • row
  • +
  • rowheader
  • +
  • switch
  • +
  • tab
  • +
  • tooltip
  • +
  • treeitem (content included in a child group element is excluded.)
  • +
+

+ When calculating a name from content for an element, user agents recursively walk through each of its descendant elements, calculate a name string for each descendant, and concatenate the resulting strings. + In two special cases, certain descendants are ignored: group descendants of treeitem elements and menu descendants of menuitem elements are omitted from the calculation. + For example, in the following tree, the name of the first tree item is Fruits; Apples, Bananas, and Oranges are omitted. +

+

+<ul role="tree">
+  <li role="treeitem">Fruits
+    <ul role="group">
+      <li role="treeitem">Apples</li>
+      <li role="treeitem">Bananas</li>
+      <li role="treeitem">Oranges</li>
+    </ul>
+  </li>
+</ul>
+          
+

+ If an element with one of the above roles that supports naming from child content is named by using aria-label or aria-labelledby, content contained in the element and its descendants is hidden from assistive technology users unless the descendant content is referenced by aria-labelledby. + It is strongly recommended to avoid using either of these attributes to override content of one of the above elements except in rare circumstances where hiding content from assistive technology users is beneficial. + In addition, in situations where visible content is hidden from assistive technology users by use of one of these attributes, thorough testing with assistive technologies is particularly important. +

+
+ +
+

Naming with a String Attribute Via aria-label

+

+ The aria-label property enables authors to name an element with a string that is not visually rendered. + For example, the name of the following button is "Close". +

+
<button type="button" aria-label="Close">X</button>
+

+ The aria-label property is useful when there is no visible text content that will serve as an appropriate accessible name. +

+

+ The aria-label property affects assistive technology users in one of two different ways, depending on the role of the element to which it is applied. + When applied to an element with one of the roles that supports naming from child content, aria-label hides descendant content from assistive technology users and replaces it with the value of aria-label. + However, when applied to nearly any other type of element, assistive technologies will render both the value of aria-label and the content of the element. + For example, the name of the following navigation region is "Product". +

+

+<nav aria-label="Product">
+  <!-- list of navigation links to product pages -->
+</nav>
+

+ When encountering this navigation region, a screen reader user will hear the name and role of the element, e.g., "Product navigation region", and then be able to read through the links contained in the region. +

+
    +
  1. + If aria-label is applied to an element with one of the roles that supports naming from child content, content contained in the element and its descendants is hidden from assistive technology users. + It is strongly recommended to avoid using aria-label to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial. +
  2. +
  3. There are certain types of elements, such as paragraphs and list items, that should not be named with aria-label. They are identified in the table in the Accessible Name Guidance by Role section.
  4. +
  5. Because the value of aria-label is not rendered visually, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
  6. +
  7. When a user interface is translated into multiple languages, ensure that aria-label values are translated.
  8. +
+
+ +
+

Naming with Referenced Content Via aria-labelledby

+

+ The aria-labelledby property enables authors to reference other elements on the page to define an accessible name. + For example, the following switch is named by the text content of a previous sibling element. +

+

+<span id="night-mode-label">Night mode</span>
+<span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
+

+ Note that while using aria-labelledby is similar in this situation to using an HTML label element with the for attribute, one significant difference is that browsers do not automatically make clicking on the labeling element activate the labeled element; that is an author responsibility. + However, HTML label cannot be used to label a span element. + Fortunately, an HTML input with type="checkbox" allows the ARIA switch role, so when feasible, using the following approach creates a more robust solution. +

+

+<label for="night-mode">Night mode</label>
+<input type="checkbox" role="switch" id="night-mode">
+

The aria-labelledby property is useful in a wide variety of situations because:

+
    +
  • It has the highest precedence when browsers calculate accessible names, i.e., it overrides names from child content and all other naming attributes, including aria-label.
  • +
  • It can concatenate content from multiple elements into a single name string.
  • +
  • It incorporates content from elements regardless of their visibility, i.e., it even includes content from elements with the HTML hidden attribute, CSS display: none, or CSS visibility: hidden in the calculated name string.
  • +
  • It incorporates the value of input elements, i.e., if it references a textbox, the value of the textbox is included in the calculated name string.
  • +
+

An example of referencing a hidden element with aria-labelledby could be a label for a night switch control:

+

+<span id="night-mode-label" hidden>Night mode</span>
+<input type="checkbox" role="switch" aria-labelledby="night-mode-label">
+

+ In some cases, the most effective name for an element is its own content combined with the content of another element. + Because aria-labelledby has highest precedence in name calculation, in those situations, it is possible to use aria-labelledby to reference both the element itself and the other element. + In the following example, the "Read more..." link is named by the element itself and the article’s heading, resulting in a name for the link of "Read more... 7 ways you can help save the bees". +

+

+<h2 id="bees-heading">7 ways you can help save the bees</h2>
+<p>Bees are disappearing rapidly. Here are seven things you can do to help.</p>
+<p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
+

+ When multiple elements are referenced by aria-labelledby, text content from each referenced element is concatenated in the order specified in the aria-labelledby value. + If an element is referenced more than one time, only the first reference is processed. + When concatenating content from multiple elements, browsers trim leading and trailing white space and separate content from each element with a single space. +

+

+<button id="download-button" aria-labelledby="download-button download-details">Download</button>
+<span id="download-details">PDF, 2.4 MB</span>
+

In the above example, the accessible name of the button will be "Download PDF, 2.4 MB", with a space between "Download" and "PDF", and not "DownloadPDF, 2.4 MB".

+
    +
  1. The aria-labelledby property cannot be chained, i.e., if an element with aria-labelledby references another element that also has aria-labelledby, the aria-labelledby attribute on the referenced element will be ignored.
  2. +
  3. If an element is referenced by aria-labelledby more than one time during a name calculation, the second and any subsequent references will be ignored.
  4. +
  5. There are certain types of elements, such as paragraphs and list items, that should not be named with aria-labelledby. They are identified in the table in the Accessible Name Guidance by Role section.
  6. +
  7. + If aria-labelledby is applied to an element with one of the roles that supports naming from child content, content contained in the element and its descendants is hidden from assistive technology users unless it is also referenced by aria-labelledby. + It is strongly recommended to avoid using this attribute to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial. +
  8. +
  9. Because calculating the name of an element with aria-labelledby can be complex and reference hidden content, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
  10. +
+
+ +
+

Naming Form Controls with the Label Element

+

+ The HTML label element enables authors to identify content that serves as a label and associate it with a form control. + When a label element is associated with a form control, browsers calculate an accessible name for the form control from the label content. +

+

+ For example, text displayed adjacent to a checkbox may be visually associated with the checkbox, so it is understood as the checkbox label by users who can perceive that visual association. + However, unless the text is programmatically associated with the checkbox, assistive technology users will experience a checkbox without a label. + Wrapping the checkbox and the labeling text in a label element as follows gives the checkbox an accessible name. +

+

+<label>
+  <input type="checkbox" name="subscribe">
+  subscribe to our newsletter
+</label>
+

+ A form control can also be associated with a label by using the for attribute on the label element. + This allows the label and the form control to be siblings or have different parents in the DOM, but requires adding an id attribute to the form control, which can be error-prone. + When possible, use the above encapsulation technique for association instead of the following for attribute technique. +

+

+<input type="checkbox" name="subscribe" id="subscribe_checkbox">
+<label for="subscribe_checkbox">subscribe to our newsletter</label>
+

+ Using the label element is an effective technique for satisfying Rule 2: Prefer Visible Text. + It also satisfies Rule 3: Prefer Native Techniques. + Native HTML labels offer an important usability and accessibility advantage over ARIA labeling techniques: browsers automatically make clicking the label equivalent to clicking the form control. + This increases the hit area of the form control. +

+
+ +
+

Naming Fieldsets with the Legend Element

+

+ The HTML fieldset element can be used to group form controls, and the legend element can be used to give the group a name. + For example, a group of radio buttons can be grouped together in a fieldset, where the legend element labels the group for the radio buttons. +

+

+<fieldset>
+  <legend>Select your starter class</legend>
+  <label><input type="radio" name="starter-class" value="green">Green</label>
+  <label><input type="radio" name="starter-class" value="red">Red</label>
+  <label><input type="radio" name="starter-class" value="blue">Blue</label>
+</fieldset>
+

+ This grouping technique is particularly useful for presenting multiple choice questions. + It enables authors to associate a question with a group of answers. + If a question is not programmatically associated with its answer options, assistive technology users may access the answers without being aware of the question. +

+

+ Similar benefits can be gained from grouping and naming other types of related form fields using fieldset and legend. +

+

+<fieldset>
+  <legend>Shipping address</legend>
+  <p><label>Full name <input name="name" required></label></p>
+  <p><label>Address line 1 <input name="address-1" required></label></p>
+  <p><label>Address line 2 <input name="address-2"></label></p>
+  ...
+</fieldset>
+<fieldset>
+  <legend>Billing address</legend>
+  ...
+</fieldset>
+

Using the legend element to name a fieldset element satisfies Rule 2: Prefer Visible Text and Rule 3: Prefer Native Techniques.

+
+ +
+

Naming Tables and Figures with Captions

+

+ The accessible name for HTML table and figure elements can be derived from a child caption or figcaption element, respectively. + Tables and figures often have a caption to explain what they are about, how to read them, and sometimes giving them numbers used to refer to them in surrounding prose. + Captions can help all users better understand content, but are especially helpful to users of assistive technologies. +

+

+ In HTML, the table element marks up a data table, and can be provided with a caption using the caption element. + If the table element does not have aria-label or aria-labelledby, then the caption will be used as the accessible name. + For example, the accessible name of the following table is Special opening hours. +

+

+<table>
+  <caption>Special opening hours</caption>
+  <tr><td>30 May</td><td>Closed</td></tr>
+  <tr><td>6 June</td><td>11:00-16:00</td></tr>
+</table>
+

The following example gives the table a number (Table 1) so it can be referenced.

+

+<table>
+  <caption>Table 1. Traditional dietary intake of Okinawans and other Japanese circa 1950</caption>
+  <thead>
+    <tr>
+      <th></th>
+      <th>Okinawa, 1949</th>
+      <th>Japan, 1950</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr>
+      <th>Total calories</th>
+      <td>1785</td>
+      <td>2068</td>
+
+      [...]
+
+</table>
+

Note: Above table content is from Caloric restriction, the traditional Okinawan diet, and healthy aging: the diet of the world's longest-lived people and its potential impact on morbidity and life span.

+

+ If a table is named using aria-label or aria-labelledby, then a caption element, if present, will become an accessible description. + For an example, see Describing Tables and Figures with Captions. +

+

+ Similarly, an HTML figure element can be given a caption using the figcaption element. + The caption can appear before or after the figure, but it is more common for figures to have the caption after. +

+

+<figure>
+  <img alt="Painting of a person walking in a desert." src="Hole_JesusalDesierto.jpg">
+  <figcaption>Jesus entering the desert as imagined by William Hole, 1908</figcaption>
+</figure>
+

+ Like with table elements, if a figure is not named using aria-label or aria-labelledby, the content of the figcaption element will be used as the accessible name. + However unlike table elements, if the figcaption element is not used for the name, it does not become an accessible description unless it is referenced by aria-describedby. + Nevertheless, assistive technologies will render the content of a figcaption regardless of whether it is used as a name, description, or neither. +

+

Using the caption element to name a table element, or a figcaption element to name a figure element, satisfies Rule 2: Prefer Visible Text and Rule 3: Prefer Native Techniques.

+
+ +
+

Fallback Names Derived from Titles and Placeholders

+

+ When an accessible name is not provided using one of the primary techniques (e.g., the aria-label or aria-labelledby attributes), or native markup techniques (e.g., the HTML label element, or the alt attribute of the HTML img element), browsers calculate an accessible name from other attributes as a fallback mechanism. + Because the attributes used in fallback name calculation are not intended for naming, they typically yield low quality accessible names that are not effective. + So, As advised by Rule 4: Avoid Browser Fallback, prefer the explicit labeling techniques described above over fallback techniques described in this section. +

+

+ Any HTML element can have a title attribute specified. + The title attribute may be used as the element's fallback accessible name. + The title attribute is commonly presented visually as a tooltip when the user hovers over the element with a pointing device, which is not particularly discoverable, and is also not accessible to visual users without a pointing device. +

+

For example, a fieldset element without a legend element child, but with a title attribute, gets its accessible name from the title attribute.

+

+<fieldset title="Select your starter class">
+  <label><input type="radio" name="starter-class" value="green">Green</label>
+  <label><input type="radio" name="starter-class" value="red">Red</label>
+  <label><input type="radio" name="starter-class" value="blue">Blue</label>
+</fieldset>
+

+ For the HTML input and textarea elements, the placeholder attribute is used as a fallback labeling mechanism if nothing else (including the title attribute) results in a label. + It is better to use a label element, since it does not disappear visually when the user focuses the form control. +

+

+<!-- Using a <label> is recommended -->
+<label>Search <input type=search name=q></label>
+
+<!-- A placeholder is used as fallback -->
+<input type=search name=q placeholder="Search">
+
+
+ +
+

Composing Effective and User-friendly Accessible Names

+

+ For assistive technology users, especially screen reader users, the quality of accessible names is one of the most significant contributors to usability. + Names that do not provide enough information reduce users' effectiveness while names that are too long reduce efficiency. + And, names that are difficult to understand reduce effectiveness, efficiency, and enjoyment. +

+

The following guidelines provide a starting point for crafting user friendly names.

+ +
+ +
+

Accessible Name Guidance by Role

+

+ Certain elements always require a name, others may usually or sometimes require a name, and still others should never be named. + The table below lists all ARIA roles and provides the following information for each : +

+
+
Necessity of Naming
+
+ Indicates how necessary it is for authors to add a naming attribute or element to supplement or override the content of an element with the specified role. + This column may include one of the following values: +
    +
  • + Required Only If Content Insufficient: An element with this role is named by its descendant content. + If aria-label or aria-labelledby is applied, content contained in the element and its descendants is hidden from assistive technology users unless it is also referenced by aria-labelledby. + Avoid hiding descendant content except in the rare circumstances where doing so benefits assistive technology users. +
  • +
  • Required: The ARIA specification requires authors to provide a name; a missing name causes accessibility validators to report an error.
  • +
  • Recommended: Providing a name is strongly recommended.
  • +
  • Discretionary: Naming is either optional or, in the circumstances described in the guidance column, is discouraged.
  • +
  • Do Not Name: Naming is strongly discouraged even if it is technically permitted; often assistive technologies do not render a name even if provided.
  • +
  • Prohibited: The ARIA specification does not permit the element to be named; If a name is specified, accessibility validators will report an error.
  • +
+
+
Guidance:
+
+ Provides information to help determine if providing a name is beneficial, and if so, describes any recommended techniques. +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
roleNecessity of NamingGuidance
alertDiscretionary + Some screen readers announce the name of an alert before announcing the content of the alert. + Thus, aria-label provides a method for prefacing the visible content of an alert with text that is not displayed as part of the alert. + Using aria-label is functionally equivalent to providing off-screen text in the contents of the alert, except off-screen text would be announced by screen readers that do not support aria-label on alert elements. +
alertdialogRequiredUse aria-labelledby if a visible label is present, otherwise use aria-label.
applicationRequiredUse aria-labelledby if a visible label is present, otherwise use aria-label.
articleRecommended +
    +
  • Recommended to distinguish articles from one another; helps users when navigating among articles.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
+
bannerDiscretionary +
    +
  • Necessary in the uncommon circumstance where two banner landmark regions are present on the same page. It is otherwise optional.
  • +
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
  • See the Banner Landmark section.
  • +
+
blockquoteDiscretionary + If a visible label is present, associating it with the blockquote by using aria-labelledby could benefit some assistive technology users. +
buttonRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
+
captionProhibited
cellRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • Note that a name is not required; assistive technologies expect an empty cell in a table to be represented by an empty name.
  • +
  • Note that associated row or column headers do not name a cell; the name of a cell in a table is its content. Headers are complementary information.
  • +
+
checkboxRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • If based on HTML type="checkbox", use a label element.
  • +
  • Otherwise, reference visible content via aria-labelledby.
  • +
+
codeProhibited
columnheaderRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • If the columnheader role is implied from an HTML th, the HTML abbr attribute can be used to specify an abbreviated version of the name that is only announced when screen readers are reading an associated cell within the table, grid, or treegrid.
  • +
+
comboboxRequired +
    +
  • If the combobox role is applied to an HTML select or input element, can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
+
complementaryRecommended +
    +
  • Naming is necessary when two complementary landmark regions are present on the same page.
  • +
  • Naming is recommended even when one complementary region is present to help users understand the purpose of the region's content when navigating among landmark regions.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Complementary Landmark section.
  • +
+
contentinfoDiscretionary +
    +
  • Necessary in the uncommon circumstance where two contentinfo landmark regions are present on the same page. It is otherwise optional.
  • +
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
+
definitionRecommendedReference the term being defined with role="term", using aria-labelledby.
deletionProhibited
dialogRequiredUse aria-labelledby if a visible label is present, otherwise use aria-label.
directoryDiscretionary +
    +
  • Naming can help users understand the purpose of the directory.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
+
documentDiscretionary + Elements with the document role are contained within an element with the application role, which is required to have a name. + Typically, the name of the application element will provide sufficient context and identity for the document element. + Because the application element is used only to create unusual, custom widgets, careful assessment is necessary to determine whether or not adding an accessible name is beneficial. +
emphasisProhibited
feedRecommended +
    +
  • Helps screen reader users understand the context and purpose of the feed.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Feed Pattern.
  • +
+
figureRecommended +
    +
  • For HTML, use the figure and figcaption elements. The figcaption will serve as the accessible name for the figure. See the Naming Tables and Figures with Captions section.
  • +
  • When not using HTML, or when retrofitting legacy HTML, use the aria-labelledby on the figure, pointing to the figure's caption.
  • +
  • If there is no visible caption, aria-label can be used.
  • +
+
formRecommended +
    +
  • Helps screen reader users understand the context and purpose of the form landmark.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Form Landmark section.
  • +
+
genericProhibited
gridRequired +
    +
  • If the grid is applied to an HTML table element, then the accessible name can be derived from the table's caption element.
  • +
  • Otherwise, use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
+
gridcellRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • Note that a name is not required; assistive technologies expect an empty cell in a grid to be represented by an empty name.
  • +
  • Note that associated row or column headers do not name a gridcell; the name of a cell in a grid is its content. Headers are complementary information.
  • +
+
groupDiscretionary +
    +
  • When using the HTML fieldset element, the accessible name can be derived from the legend element.
  • +
  • When using the HTML details element, do not provide an accessible name for this element. The user interacts with the summary element, and that can derive its accessible name from its contents.
  • +
  • When using the HTML optgroup element, use the label attribute.
  • +
  • Otherwise, use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
+
headingRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
+
insertionProhibited
imgRequiredFor the HTML img element, use the alt attribute. For other elements with the img role, use aria-labelledby or aria-label.
linkRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
+
listDiscretionary +
    +
  • Potentially beneficial for users of screen readers that support both list names and navigation among lists on a page.
  • +
  • Potentially a source of distracting or undesirable screen reader verbosity, especially if nested within a named container, such as a navigation region.
  • +
  • Can be named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
+
listboxRequired +
    +
  • If the listbox role is applied to an HTML select element (with the multiple attribute or a size attribute having a value greater than 1), can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
  • See the Listbox Pattern.
  • +
+
listitemDo Not NameNaming is not supported by assistive technologies; it is necessary to include relevant content within the list item.
logDiscretionary + Some screen readers announce the name of a log element before announcing the content of the log element. + Thus, aria-label provides a method for prefacing the visible content of a log element with text that is not displayed as part of the log element. + Using aria-label is functionally equivalent to providing off-screen text in the contents of the log element, except off-screen text would be announced by screen readers that do not support aria-label on log elements. +
mainDiscretionary +
    +
  • Potentially helpful for orienting assistive technology users, especially in single-page applications where main content changes happen without generating a page load event.
  • +
  • Can be named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
  • See the Main Landmark section.
  • +
+
marqueeDiscretionaryUse aria-labelledby if a visible label is present, otherwise use aria-label.
mathRecommended +
    +
  • If the math element has only presentational children and the accessible name is intended to convey the mathematical expression, use aria-label to provide a string that represents the expression.
  • +
  • If the math element contains navigable content that conveys the mathematical expression and a visible label for the expression is present, use aria-labelledby.
  • +
  • Otherwise, use aaria-label to name the expression, e.g., aria-label="Pythagorean Theorem".
  • +
+
menuRecommended +
    +
  • Use aria-labelledby to refer to the menuitem or button that controls this element's display.
  • +
  • Otherwise, use aria-label.
  • +
  • See the Menu and Menubar Pattern.
  • +
+
menubarRecommended +
    +
  • + Helps screen reader users understand the context and purpose of menuitem elements in a menubar. + Naming a menubar is comparable to naming a menu button. + The name of a button that opens a menu conveys the purpose of the menu it opens. + Since a menubar element is displayed persistently, a name on the menubar can serve that same purpose. +
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Menu and Menubar Pattern.
  • +
+
menuitemRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • Note: content contained within a child menu is automatically excluded from the accessible name calculation.
  • +
  • See the Menu and Menubar Pattern.
  • +
+
menuitemcheckboxRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • See the Menu and Menubar Pattern.
  • +
+
menuitemradioRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • See the Menu and Menubar Pattern.
  • +
+
meterRequired +
    +
  • If based on an HTML meter element, can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
+
navigationRecommended +
    +
  • Helps screen reader users understand the context and purpose of the navigation landmark.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Navigation Landmark section.
  • +
+
noneProhibitedAn element with role="none" is not part of the accessibility tree (except in error cases). Do not use aria-labelledby or aria-label.
noteDiscretionary +
    +
  • Naming is optional, but can help screen reader users understand the context and purpose of the note.
  • +
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
+
optionRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • See the Combobox Pattern.
  • +
+
paragraphProhibited
presentationProhibitedAn element with role="presentation" is not part of the accessibility tree (except in error cases). Do not use aria-labelledby or aria-label.
progressbarRequired +
    +
  • If the progressbar role is applied to an HTML progress element, can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
+
radioRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • If based on HTML type="checkbox", use a label element.
  • +
  • Otherwise, reference visible content via aria-labelledby.
  • +
+
radiogroupRequired +
    +
  • Recommended to help assistive technology users understand the purpose of the group of radio buttons.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Radio Group Pattern.
  • +
+
regionRequired +
    +
  • Helps screen reader users understand the context and purpose of the landmark.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Region Landmark section.
  • +
+
row + Required Only If Content Insufficient + AND descendant of a treegrid + AND the row is focusable + + When row elements are focusable in a treegrid, screen readers announce the entire contents of a row when navigating by row. + This is typically the most appropriate behavior. + However, in some circumstances, it could be beneficial to change the order in which cells are announced or exclude announcement of certain cells by using aria-labelledby to specify which cells to announce. +
rowgroupDo Not NameNaming is not supported by assistive technologies.
rowheaderRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • If the rowheader role is implied from an HTML th, the HTML abbr attribute can be used to specify an abbreviated version of the name that is only announced when screen readers are reading an associated cell within the table, grid, or treegrid.
  • +
+
scrollbarDiscretionary +
    +
  • Naming is optional, but can potentially help screen reader users understand the purpose of the scrollbar. The purpose is also conveyed using the aria-controls attribute, which is required for scrollbar.
  • +
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
+
searchRecommended +
    +
  • Helps screen reader users understand the context and purpose of the search landmark.
  • +
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
  • See the Search Landmark section.
  • +
+
searchboxRequired +
    +
  • If the searchbox role is applied to an HTML input element, can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
+
separatorDiscretionary +
    +
  • Recommended if there is more than one focusable separator element on the page.
  • +
  • Can help assistive technology users understand the purpose of the separator.
  • +
  • Named using aria-labelledby if a visible label is present, otherwise with aria-label.
  • +
+
sliderRequired +
    +
  • If the slider role is applied to an HTML input element, can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
  • See the Slider Pattern and the Slider (Multi-Thumb) Pattern.
  • +
+
spinbuttonRequired +
    +
  • If the textbox role is applied to an HTML input element, can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
  • See the Spinbutton Pattern.
  • +
+
statusDiscretionary + Some screen readers announce the name of a status element before announcing the content of the status element. + Thus, aria-label provides a method for prefacing the visible content of a status element with text that is not displayed as part of the status element. + Using aria-label is functionally equivalent to providing off-screen text in the contents of the status element, except off-screen text would be announced by screen readers that do not support aria-label on status elements. +
strongProhibited
subscriptProhibited
superscriptProhibited
switchRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • If based on HTML type="checkbox", use a label element.
  • +
  • Otherwise, reference visible content via aria-labelledby.
  • +
+
tabRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
+
tableRequired +
    +
  • If using HTML table element, use the caption element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
  • See the Table Pattern.
  • +
+
tablistRecommended +
    +
  • Helps screen reader users understand the context and purpose of the tablist.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Carousel Pattern and Tabs Pattern.
  • +
+
tabpanelRequired + +
termDo Not NameSince a term is usually the name for the role="definition" element, it could be confusing if the term itself also has a name.
textboxRequired +
    +
  • If the textbox role is applied to an HTML input or textarea element, can be named with an HTML label element.
  • +
  • Otherwise use aria-labelledby if a visible label is present.
  • +
  • Use aria-label if a visible label is not present.
  • +
+
timeDo Not NameNaming is not supported by assistive technologies.
timerDiscretionary + Some screen readers announce the name of a timer element before announcing the content of the timer element. + Thus, aria-label provides a method for prefacing the visible content of a timer element with text that is not displayed as part of the timer element. + Using aria-label is functionally equivalent to providing off-screen text in the contents of the timer element, except off-screen text would be announced by screen readers that do not support aria-label on timer elements. +
toolbarRecommended +
    +
  • If there is more than one toolbar element on the page, naming is required.
  • +
  • Helps assistive technology users to understand the purpose of the toolbar, even when there is only one toolbar on the page.
  • +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Toolbar Pattern.
  • +
+
tooltipRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
+
treeRequired +
    +
  • Use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Tree View Pattern.
  • +
+
treegridRequired +
    +
  • If the treegrid is applied to an HTML table element, then the accessible name can be derived from the table's caption element.
  • +
  • Otherwise, use aria-labelledby if a visible label is present, otherwise use aria-label.
  • +
  • See the Treegrid Pattern.
  • +
+
treeitemRequired Only If Content Insufficient +
    +
  • Warning! Using aria-label or aria-labelledby will hide any descendant content from assistive technologies.
  • +
  • Ideally named by visible, descendant content.
  • +
  • Note: content contained within a child group is automatically excluded from the accessible name calculation.
  • +
  • See the Tree View Pattern.
  • +
+
+
+ +
+

Accessible name calculation

+

+ User agents construct an accessible name string for an element by walking through a list of potential naming methods and using the first that generates a name. + The algorithm they follow is defined in the accessible name specification. + It is roughly like the following: +

+
    +
  1. The aria-labelledby property is used if present.

  2. +
  3. If the name is still empty, the aria-label property is used if present.

  4. +
  5. +

    If the name is still empty, then host-language-specific attributes or elements are used if present. For HTML, these are, depending on the element:

    +
    +
    input whose type attribute is in the Button, Submit Button, or Reset Button state
    +
    The value attribute.
    + +
    input whose type attribute is in the Image Button state
    +
    img
    +
    area
    +
    The alt attribute.
    + +
    fieldset
    +
    The first child legend element.
    + +
    Other form elements
    +
    The associated label element(s).
    + +
    figure
    +
    The first child figcaption element.
    + +
    table
    +
    The first child caption element.
    +
    +
  6. +
  7. If the name is still empty, then for elements with a role that supports naming from child content, the content of the element is used.

  8. +
  9. +

    Finally, if the name is still empty, then other fallback host-language-specific attributes or elements are used if present. For HTML, these are, depending on the element:

    +
    +
    input whose type attribute is in the Text, Password, Search, Telephone, or URL states
    +
    textarea
    +
    The title attribute. Otherwise, the placeholder attribute.
    + +
    input whose type attribute is in the Submit Button state
    +
    A localized string of the word "submit".
    + +
    input whose type attribute is in the Reset Button state
    +
    A localized string of the word "reset".
    + +
    input whose type attribute is in the Image Button state
    +
    The title attribute. Otherwise, a localized string of the phrase "Submit Query".
    + +
    summary
    +
    The word "Details".
    + +
    Other elements
    +
    The title attribute.
    +
    +
  10. +
+

+ The final step is a fallback mechanism. Generally when labeling an element, use one of the non-fallback mechanisms. +

+

+ When calculating a name from content, the user agent walks through all descendant nodes except in the cases of treeitem and menuitem as described below. + And, when following references in an aria-labelledby attribute, it similarly walks the tree of each referenced element. + Thus, the naming algorithm is recursive. + The following two sections explain non-recursive and recursive examples of how the algorithm works. +

+

+ When calculating a name from content for the treeitem role, descendant content of child group elements are not included. + For example, in the following tree, the name of the first tree item is Fruits; Apples, Bananas, and Oranges are automatically omitted. +

+

+<ul role="tree">
+  <li role="treeitem">Fruits
+    <ul role="group">
+      <li role="treeitem">Apples</li>
+      <li role="treeitem">Bananas</li>
+      <li role="treeitem">Oranges</li>
+    </ul>
+  </li>
+</ul>
+

+ Similarly, when calculating a name from content for the menuitem role, descendant content of child menu elements are not included. + So, the name of the first parent menuitem in the following menu is Fruits. +

+

+<ul role="menu">
+  <li role="menuitem">Fruits
+    <ul role="menu">
+      <li role="menuitem">Apples</li>
+      <li role="menuitem">Bananas</li>
+      <li role="menuitem">Oranges</li>
+    </ul>
+  </li>
+</ul>
+ +
+

Examples of non-recursive accessible name calculation

+

Consider an input element that has no associated label element and only a name attribute and so does not have an accessible name (do not do this):

+
<input name="code">
+

If there is a placeholder attribute, then it serves as a naming fallback mechanism (avoid doing this):

+ +

+<input name="code"
+  placeholder="One-time code">
+ +

If there is also a title attribute, then it is used as the accessible name instead of placeholder, but it is still a fallback (avoid doing this):

+

+<input name="code"
+  placeholder="123456"
+  title="One-time code">
+ +

If there is also a label element (recommended), then that is used as the accessible name, and the title attribute is instead used as the accessible description:

+

+<label>One-time code
+  <input name="code"
+    placeholder="123456"
+    title="Get your code from the app.">
+</label>
+ +

If there is also an aria-label attribute (not recommended unless it adds clarity for assistive technology users), then that becomes the accessible name, overriding the label element:

+ + +

+<label>Code
+  <input name="code"
+    aria-label="One-time code"
+    placeholder="123456"
+    title="Get your code from the app.">
+</label>
+ +

If there is also an aria-labelledby attribute, that wins over the other elements and attributes (the aria-label attribute ought to be removed if it is not used):

+

+<p>Please fill in your <span id="code-label">one-time code</span> to log in.</p>
+<p>
+  <label>Code
+    <input name="code"
+    aria-labelledby="code-label"
+    aria-label="This is ignored"
+    placeholder="123456"
+    title="Get your code from the app.">
+  </label>
+</p>
+
+ +
+

Examples of recursive accessible name calculation

+

+ The accessible name calculation algorithm will be invoked recursively when necessary. + An aria-labelledby reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node. +

+ +

In this example, the label for the button is computed by recursing into each child node, resulting in Move to trash.

+
<button>Move to <img src="bin.svg" alt="trash"></button>
+

When following an aria-labelledby reference, the algorithm avoids following the same reference twice to avoid infinite loops.

+

+ In this example, the label for the button is computed by first following the aria-labelledby reference to the parent element, and then computing the label for that element from the child nodes, first visiting the button element again but ignoring the aria-labelledby reference and instead using the aria-label, and then visiting the next child (the text node). + The resulting label is Remove meeting: Daily status report. +

+

+<div id="meeting-1">
+  <button aria-labelledby="meeting-1" aria-label="Remove meeting:">X</button>
+  Daily status report
+</div>
+
+
+ +
+

Describing Techniques

+
+

Describing by referencing content with aria-describedby

+

+ The aria-describedby property works similarly to the aria-labelledby property. + For example, a button could be described by a sibling paragraph. +

+

+<button aria-describedby="trash-desc">Move to trash</button>
+...
+<p id="trash-desc">Items in the trash will be permanently removed after 30 days.</p>
+

+ Descriptions are reduced to text strings. + For example, if the description contains an HTML img element, a text equivalent of the image is computed. +

+

+<button aria-describedby="trash-desc">Move to <img src="bin.svg" alt="trash"></button>
+...
+<p id="trash-desc">Items in <img src="bin.svg" alt="the trash"> will be permanently removed after 30 days.</p>
+

+ As with aria-labelledby, it is possible to reference an element using aria-describedby even if that element is hidden. + For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. + The description could also be referenced from the text field directly with aria-describedby. + In the following example, the accessible description for the input element is Your username is the name that you use to log in to this service. +

+

+<label for="username">Username</label>
+<input id="username" name="username" aria-describedby="username-desc">
+<button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
+<p id="username-desc" hidden>
+  Your username is the name that you use to log in to this service.
+</p>
+
+ +
+

Describing Tables and Figures with Captions

+

+ In HTML, if the table is named using aria-label or aria-labelledby, a child caption element becomes an accessible description. + For example, a preceding heading might serve as an appropriate accessible name, and the caption element might contain a longer description. + In such a situation, aria-labelledby could be used on the table to set the accessible name to the heading content and the caption would become the accessible description. +

+

+<h2 id="events-heading">Upcoming events</h2>
+<table aria-labelledby="events-heading">
+  <caption>
+    Calendar of upcoming events, weeks 27 through 31, with each week starting with
+    Monday. The first column is the week number.
+  </caption>
+  <tr><th>Week</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th></tr>
+  <tr><td>27</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+  <tr><td>28</td><td></td><td></td><td></td><td></td><td></td><td></td><td><a href="/events/9856">Crown Princess's birthday</a></td></tr>
+  <tr><td>29</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+  <tr><td>30</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+  <tr><td>31</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+</table>
+

+ The HTML figure element can get its accessible name from its figcaption element, but it will not be used as the accessible description, even if it was not used as the accessible name. + If the figcaption element is appropriate as an accessible description, and the accessible name is set using aria-labelledby or aria-label, then the figcaption can be explicitly set as the accessible description using the aria-describedby attribute. +

+

+<h2 id="neutron">Neutron</h2>
+<figure aria-labelledby="neutron" aria-describedby="neutron-caption">
+  <img src="neutron.svg" alt="Within the neutron are three quarks (blue 'u', red 'd', green 'd') that are interconnected.">
+  <figcaption id="neutron-caption">
+    The quark content of the neutron. The color assignment of individual quarks is
+    arbitrary, but all three colors must be present. Forces between quarks are
+    mediated by gluons.
+  </figcaption>
+</figure>
+
+ +
+

Descriptions Derived from Titles

+

If an accessible description was not provided using the aria-describedby attribute or one of the primary host-language-specific attributes or elements (e.g., the caption element for table), then, for HTML, if the element has a title attribute, that is used as the accessible description.

+

+ A visible description together with aria-describedby is generally recommended. + If a description that is not visible is desired, then the title attribute can be used, for any HTML element that can have an accessible description. +

+

Note that the title attribute might not be accessible to some users, in particular sighted users not using a screen reader and not using a pointing device that supports hover (e.g., a mouse).

+

For example, an input element with input constrained using the pattern attribute can use the title attribute to describe what the expected input is.

+

+<label> Part number:
+  <input pattern="[0-9][A-Z]{3}" name="part"
+    title="A part number is a digit followed by three uppercase letters."/>
+</label>
+

The title attribute in this case can be shown to the user as a tooltip when the user hovers or focuses the control, but also as part of the error message when the user agent validates the form, if the input element's value doesn't match the pattern.

+

As another example, a link can use the title attribute to describe the link in more detail.

+

+<a href="http://twitter.com/W3C"
+  title="Follow W3C on Twitter">
+  <img src="/2008/site/images/Twitter_bird_logo_2012.svg"
+    alt="Twitter" class="social-icon" height="40" />
+</a>
+
+
+ +
+

Accessible description calculation

+

+ Like the accessible name calculation, the accessible description calculation produces a text string. +

+

+ The accessible description calculation algorithm is the same as the accessible name calculation algorithm except for a few branch points that depend on whether a name or description is being calculated. + In particular, when accumulating text for an accessible description, the algorithm uses aria-describedby instead of aria-labelledby. +

+

+ User agents construct an accessible description string for an element by walking through a list of potential description methods and using the first that generates a description. + The algorithm they follow is defined in the accessible name specification. + It is roughly like the following: +

+
    +
  1. The aria-describedby property is used if present.

  2. +
  3. +

    If the description is still empty, then host-language-specific attributes or elements are used if present, if it wasn't already used as the accessible name. For HTML, these are, depending on the element:

    +
    +
    input whose type attribute is in the Button, Submit Button, or Reset Button state
    +
    The value attribute.
    + +
    summary
    +
    The element's subtree.
    + +
    table
    +
    The first child caption element.
    +
    +
  4. +
  5. +

    Finally, if the description is still empty, then other host-language-specific attributes or elements are used if present, if it wasn't already used for the accessible name. For HTML, this is the title attribute.

    +
  6. +
+
+ + + \ No newline at end of file diff --git a/content/practices/range-related-properties/range-related-properties-practice.html b/content/practices/range-related-properties/range-related-properties-practice.html new file mode 100644 index 0000000000..b83748b290 --- /dev/null +++ b/content/practices/range-related-properties/range-related-properties-practice.html @@ -0,0 +1,342 @@ + + + + + +Communicating Value and Limits for Range Widgets + + +

Communicating Value and Limits for Range Widgets

+
+

Introduction

+

+ ARIA defines the following roles as range widgets, which means they communicate a value that is typically numeric and constrained to defined limits. +

+ +

+ For example, a spin button for choosing a day within the month of January would allow integer values that range from 1 to 31. + In some cases, the value is represented numerically, but is not presented as a number to users. + For instance, a spin button for choosing a day of the week could support values from 1 to 7 but they could be presented to the user as day names, e.g., "Monday", "Tuesday", etc. +

+

+ This section describes considerations for using the following four properties that communicate characteristics of a range widget: +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyDefinition
aria-valueminDefines the minimum value allowed by a range widget.
aria-valuemaxDefines the maximum value allowed by a range widget.
aria-valuenowDefines the current value of a range widget. This value is a number greater than or equal to aria-valuemin and less than or equal to aria-valuemax (if they are specified).
aria-valuetextIf a numeric value is not sufficiently descriptive, this property can define a text description of the current value of a range widget.
+
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/content/practices/structural-roles/structural-roles-practice.html b/content/practices/structural-roles/structural-roles-practice.html new file mode 100644 index 0000000000..a1dd9c048f --- /dev/null +++ b/content/practices/structural-roles/structural-roles-practice.html @@ -0,0 +1,98 @@ + + + + + +Structural Roles + + +

Structural Roles

+
+

Introduction

+

+ ARIA provides a set of roles that convey the accessibility semantics of structures on a page. + These roles express the meaning that is conveyed by the layout and appearance of elements that organize and structure content, such as headings, lists, and tables. +

+

+ some host languages, such as HTML, include elements that express the same semantics as an ARIA role. + For instance, the HTML <p> element is mapped to accessibility APIs in exactly the same way as <div role="paragraph">. + The ARIA and HTML specifications refer to this mapping of HTML elements to ARIA attributes as implied semantics, i.e., the implied ARIA role of the HTML <p> element is paragraph. +

+
+ +
+

When to Use Structural Roles

+

+ When developing HTML, it is important to use native HTML elements where ever possible. + Do not use an ARIA role or property if it is possible to use an HTML element that has equivalent semantics. +

+

Circumstances where it is appropriate to use ARIA attributes instead of equivalent HTML are:

+
    +
  1. When the HTML element cannot be styled in a way that meets visual design requirements.
  2. +
  3. When testing reveals that browsers or assistive technologies provide better support for the ARIA equivalent.
  4. +
  5. When remediating or retrofitting legacy content and altering the underlying DOM to use the HTML would be cost prohibitive.
  6. +
  7. When building a web component to compose a custom element and the element being extended does not convey the appropriate or sufficient accessibility semantics.
  8. +
+
+ +
+

All Structural Roles and Their HTML Equivalents

+

+ The following table lists all structural roles defined in ARIA 1.2. + As described above in the section on + When to Use Structural Roles, + use an equivalent HTML element instead of an ARIA structural role unless the ARIA role does not have an HTML equivalent or one of the four circumstances that makes using ARIA necessary exists. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ARIA structural roles
ARIA RoleHTML Equivalent
applicationNo equivalent element
articlearticle
blockquoteblockquote
captioncaption
celltd
codecode
columnheaderth
definitiondd
deletiondel
directoryNo equivalent element
documentNo equivalent element
emphasisem
feedNo equivalent element
figurefigure
genericdiv, span
groupNo equivalent element
heading with aria-level="N" where N is 1, 2, 3, 4, 5, or 6h1, h2, h3, h4, h5, h6
insertionins
imgimg
listul, ol
listitemli
mathNo equivalent element
noneNo equivalent element
noteNo equivalent element
presentationNo equivalent element
paragraphp
rowtr
rowgrouptbody, thead, tfoot
rowheaderth
separator (when not focusable)hr
strongstrong
subscriptsub
superscriptsup
tabletable
termdfn
timetime
toolbarNo equivalent element
tooltipNo equivalent element
+
+ + + \ No newline at end of file