label-in-name
Mobile validation
Many elements have both a visible label and an accessible name, the programmatic name that assistive technologies use. Voice input users activate elements by speaking the words they see on screen. When the accessible name does not include the visible label, those words do not match the element, and users cannot find or activate it by voice. Screen reader users who can also see the screen hear a name that differs from what is shown. Include the visible label text, in the same order, in the accessible name. You can add extra context after the label. The simplest way is to not override the name at all, so it comes from the visible label.
Note: It is best to start the accessible name with the visible label. When the name contains the label but does not start with it, see the related accessible-name-starts-with-label validation.
Pass Patterns
Android
XML Views
The button has no contentDescription, so its accessible name is its visible text, “Refresh”.
<Button
android:id="@+id/refreshButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Refresh" />iOS
The accessibilityLabel “Refresh the list” includes the visible title, “Refresh”.
let refreshButton = UIButton(type: .system)
refreshButton.setTitle("Refresh", for: .normal)
refreshButton.accessibilityLabel = "Refresh the list"The button has no accessibilityLabel, so its accessible name is its visible title, “Refresh”.
Button("Refresh") {
refresh()
}Cross Platform
The semanticsLabel “Refresh the list” includes the visible text, “Refresh”.
ElevatedButton(
onPressed: refresh,
child: const Text('Refresh', semanticsLabel: 'Refresh the list'),
),The accessibilityLabel “Refresh the list” includes the visible text, “Refresh”.
<Pressable
accessibilityRole="button"
accessibilityLabel="Refresh the list"
onPress={refresh}
>
<Text>Refresh</Text>
</Pressable><Pressable
accessibilityRole="button"
accessibilityLabel="Label In Name — Pass because they start the same"
style={styles.button}
onPress={ ... }
>
<Text style={styles.label}>Label In Name — Pass</Text>
</Pressable>Fail Patterns
Android
XML Views
The contentDescription “Reload” does not include the visible text, “Refresh”.
<Button
android:id="@+id/refreshButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Refresh"
android:contentDescription="Reload" />iOS
The accessibilityLabel “Reload” does not include the visible title, “Refresh”.
let refreshButton = UIButton(type: .system)
refreshButton.setTitle("Refresh", for: .normal)
refreshButton.accessibilityLabel = "Reload"The accessibilityLabel “Reload” does not include the visible title, “Refresh”.
Button("Refresh") {
refresh()
}
.accessibilityLabel("Reload")Cross Platform
The semanticsLabel “Reload” does not include the visible text, “Refresh”.
ElevatedButton(
onPressed: refresh,
child: const Text('Refresh', semanticsLabel: 'Reload'),
),The accessibilityLabel “Reload” does not include the visible text, “Refresh”.
<Pressable
accessibilityRole="button"
accessibilityLabel="Reload"
onPress={refresh}
>
<Text>Refresh</Text>
</Pressable><Pressable
accessibilityRole="button"
accessibilityLabel="No label in name"
style={styles.button}
onPress={ ... }
>
<Text style={styles.label}>Label In Name — Fail</Text>
</Pressable>Try It Yourself
Using voice input
New to voice input testing, or need a refresher?
Review this article first: Practical guides for using voice input
- Turn on Voice Control on iOS, or Voice Access on Android. On Android, make sure Voice Access is listening, from the notifications panel.
- Say “Show names” on iOS, or “Show labels” on Android.
- Compare the name shown for each element with its visible label.
- Say “Tap” followed by the element's visible label, for example “Tap Refresh”.
Expected results: The name shown for each element includes its visible label, and the element is activated when you say its visible label.
Actual results: The name shown does not include the visible label, for example “Reload” for a button labeled “Refresh”, and saying the visible label does not activate the element.
Using developer tools
- iOS: In Xcode, open Xcode > Open Developer Tool > Accessibility Inspector, select the simulator or device, and point at the element. Check its Label.
- Android: In Android Studio, open the Layout Inspector and select the element. Check its
contentDescription, for Views, or its semantics, for Jetpack Compose.
Expected results: The accessible name is empty, so the visible label is used, or it includes the visible label.
Actual results: The accessible name does not include the visible label.
FAQ
How does this issue relate to 2.5.3 Label in Name?
SC 2.5.3 requires that for user interface components with a visible text label, the accessible name contains that text. When the accessible name does not include the visible label, voice input users cannot activate the element by speaking what they see, so the criterion is not met.
Why is this issue marked as Serious?
Voice input users rely on the words on screen to find and activate controls. When the accessible name does not include them, users may be unable to operate the control by voice, and need slower workarounds, such as showing numbers or a grid. This can block common tasks, so it is rated serious.
Standards and Regulations
| Standard | Success Criterion | Reference |
|---|---|---|
| WCAG 2.2 | 2.5.3 Label in Name (A) | For user interface components with labels that include text or images of text, the accessible name contains the text that is presented visually. |
| EN 301 549 | 11.2.5.3 Label in Name | Same as the WCAG text. |