Code examples
Use semantic HTML
- This semantic HTML contains all accessibility features by default.
- Placing the show password checkbox ahead of the password input increases discoverability for screen reader users.
- CSS pseudo elements are used in the checkbox label to express its state on focus of the password input.
Developer notes
Name
- Include
for="input-id
in each <label>
label to associate it with the input
- Use
aria-label="Input name"
as a last resort if a <label>
can’t be used
Role
- Identifies as some kind of secure input
State
- The show password checkbox must indicate its state on focus
Group
- Include
for="input-id
in each <label>
label to associate it with the input
- Use
<fieldset>
and <legend>
to name a group of inputs.
Focus
Related password input entries