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<CheckBox
2 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<Switch
2 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<LinearLayout
2 android:layout_width="match_parent"
3 android:layout_height="match_parent"
4 android:orientation="vertical">
5 <TextView
6 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 <CheckBox
11 android:id="@+id/termsOfUseCheck"
12 android:layout_width="wrap_content"
13 android:layout_height="wrap_content" />
14</LinearLayout>

Fail

1<CheckBox
2 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<Switch
2 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

1TextView label = new TextView(this);
2 label.setText("Agree to terms");
3
4 CheckBox checkBox = new CheckBox(this);
5
6 label.setLabelFor(checkBox.getId());
1CheckBox checkBox = new EditText(this);
2 checkBox.setText("Agree to terms");

Fail

1TextView label = new TextView(this);
2 label.setText("Agree to terms, checked");
3
4 CheckBox checkBox = new CheckBox(this);
5
6 label.setLabelFor(checkBox.getId());
1CheckBox 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)