You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPE html><htmllang="en"><head><title>Using aria-label to provide an invisible label where a visible label cannot be used</title><linkrel="stylesheet" type="text/css" href="../../css/editors.css" class="remove"></head><body><h1>Using aria-label to provide an invisible label where a visible label cannot be used</h1><sectionclass="meta"><pclass="id">ID: ARIA14</p><pclass="technology">Technology: aria</p><pclass="type">Type: Technique</p></section><sectionid="applicability"><h2>When to Use</h2>
1
+
<!DOCTYPE html>
2
+
<htmllang="en">
3
+
<head>
4
+
<title>Using aria-label to provide an accessible name where a visible label cannot be used</title>
<p>For sighted users, the context and visual appearance of an element can provide sufficient cues to determine the purpose. An example is the 'X' often used in the top right corner of pop-up <code>div</code>s (light boxes) to indicate the control for closing the div.
5
-
</p>
6
-
<p>In some situations, elements can be given the attribute <code>aria-label</code> to provide an accessible name for situations when there is no visible label due to a chosen design approach or layout but the context and visual appearance of the control make its purpose clear.</p>
18
+
</section>
19
+
<sectionid="description">
20
+
<h2>Description</h2>
21
+
<p>For sighted users, the context and visual appearance of an element can provide sufficient cues to determine the purpose. An example is the “×” often used in the top-right corner of dialogs to indicate the control for closing the dialog. While it might be visually clear that the button with the “×” symbol closes the dialog, users with assistive technologies rely on accessible names that clearly communicate the purpose of components, in this case “Close”.
22
+
</p>
23
+
<p>When no clear visible text label is available due to design decisions, the <ahref="https://www.w3.org/TR/accname-1.2/#dfn-accessible-name">accessible name</a> can be set by using the <code>aria-label</code> attribute instead, provided that the element has an implicit or explicit <ahref="https://www.w3.org/TR/wai-aria-1.2/#namefromauthor">role that supports naming</a>.</p>
24
+
25
+
<p>The <code>aria-label</code> attribute can also be used to provide an accessible name for custom controls that are not <ahref="https://html.spec.whatwg.org/multipage/forms.html#category-label">labelable elements</a>, and cannot therefore use a <code><label></code> element with the <code>for</code> attribute.</p>
7
26
8
-
<p>In other situations, elements can be given the attribute <code>aria-label</code>to provide an accessible name when the native HTML labeling element is not supported by the control - for example, when a <code>div</code>set to <code>contentEditable</code>is used instead of native form elements such as <code>input type="text"</code> or <code>textarea</code> in order to provide a richer text editing experience.</p>
27
+
<p>For instance, <code>aria-label</code>or <code>aria-labelledby</code> are the most suitable way to provide an accessible name when a <code><div></code>element is made editable using the <code>contentEditable</code>attribute, instead of native form elements such as <code><input type="text"></code> or <code><textarea></code> in order to provide a richer text editing experience.</p>
9
28
10
-
</section><sectionid="examples"><h2>Examples</h2>
29
+
</section>
30
+
<sectionid="examples">
31
+
<h2>Examples</h2>
11
32
<sectionclass="example">
12
-
<h3>A close button in a pop-up box</h3>
13
-
14
-
<p>On a page, a link displays a pop-up box (a <code>div</code>) with additional information. The 'close' element is implemented as a <code>button</code> containing merely the letter 'X'. The property <code>aria-label="close"</code> is used to provide an accessible name to the <code>button</code>.</p>
<p>On a page, a button displays a dialog (a <code><div></code> element) with additional information. The “close” element is implemented as a <code><button></code> containing merely the symbol “×”. The property <code>aria-label="close"</code> is used to provide an accessible name to the button.</p>
0 commit comments