state-in-name
The accessible name of this element contains a reference to its state.
Who might be affected
Screen Reader
Voice Control
Description
Assistive technologies such as screen readers and braille keyboards declare the accessible name along with meta-information about the type and state of the element (if supported). Therefore it is redundant to include the element's state within the labels.
Quick Fixes
contentDescription should not contain states of a view such as “enabled”, “disabled”, “checked”,”selected”.
Android (.xml):
Pass
1✓ <CheckBox2 android:id="@+id/termsOfUseCheck"3 android:layout_width="wrap_content"4 android:layout_height="wrap_content"5 android:contentDescription="Agree to terms of use" />
1✓ <Switch2 android:id="@+id/addBreakfastSwitch"3 android:layout_width="wrap_content"4 android:layout_height="wrap_content"5 android:contentDescription="Include breakfast to my order" />
1✓ <LinearLayout2 android:layout_width="match_parent"3 android:layout_height="match_parent"4 android:orientation="vertical">5 <TextView6 android:layout_width="match_parent"7 android:layout_height="wrap_content"8 android:text="Agree to terms of use"9 android:labelFor="@id/termsOfUseCheck" />10 <CheckBox11 android:id="@+id/termsOfUseCheck"12 android:layout_width="wrap_content"13 android:layout_height="wrap_content" />14</LinearLayout>
Fail
1✗ <CheckBox2 android:id="@+id/termsOfUseCheck"3 android:layout_width="wrap_content"4 android:layout_height="wrap_content"5 android:contentDescription="Agree to terms of use, checked" />
1✗ <Switch2 android:id="@+id/addBreakfastSwitch"3 android:layout_width="wrap_content"4 android:layout_height="wrap_content"5 android:contentDescription="Include breakfast to my order, not checked" />
Android (Java):
Pass
1✓ TextView label = new TextView(this);2 label.setText("Agree to terms");34 CheckBox checkBox = new CheckBox(this);56 label.setLabelFor(checkBox.getId());
1✓ CheckBox checkBox = new EditText(this);2 checkBox.setText("Agree to terms");
Fail
1✗ TextView label = new TextView(this);2 label.setText("Agree to terms, checked");34 CheckBox checkBox = new CheckBox(this);56 label.setLabelFor(checkBox.getId());
1✗ CheckBox checkBox = new CheckBox(this);2 checkBox.setText("Agree to terms, checked");
How Users Are Affected
Since assistive technologies announce elements' states according to the state that is registered to the accessibility tree, if the state name is also included in the accessible name, users might hear it twice.
WCAG Success criteria
4.1.1 parsing (A)