Content description in editable elements
Editable elements such as EditTexts
or TextViews
should not have a contentDescription
property. This ensures that screen readers can accurately navigate, describe, and interact with user-entered text within these elements.
Screen readers are designed to automatically read the text entered in editable fields. Defining a contentDescription
property can interfere with this functionality, preventing users from receiving essential feedback about their input.
- Rule Category :
Accessibility Labels
- WCAG 2.1 SC :
4.1.2 (A)
- WCAG 2.2 SC :
4.1.2 (A)
- Rule Severity :
Serious
- Supported Platforms : Native Android apps only
Success criteria
The rule checks for the following potential violations:
-
contentDescription
in editable elements
Editable fields such asEditText
orTextView
should not have acontentDescription
property. This property can interfere with the screen reader’s ability to read the entered text.
How to fix
To fix violations related to contentDescription
property in Android, follow these steps:
-
Do not use
contentDescription
Do not set acontentDescription
property onEditText
orTextView
. -
Use
hint
for accessibility labels
Use thehint
property to define the editable element’s name and purpose. -
Associate elements using
labelFor
Associate a label with an input field using thelabelFor
property. This ensures the screen reader announces the label alongside the input field.
Example
The following example scan report highlights an input field with a defined contentDescription
property. This violation prevents screen readers from reading the text entered in that field.
Fix
To correct this violation:
- Remove the
contentDescription
property. - Add a
hint
attribute to theEditText
element to provide a label. - Alternatively, use the
labelFor
property inTextView
to associate a label with the input field.
References
- Learn more about Name, Role, Value WCAG: 2.1 - 4.1.2 (Level A) guideline
- Learn more about Name, Role, Value WCAG: 2.2 - 4.1.2 (Level A) guideline
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!