A form label tells people what a control is for or what information it requires. Give each user-facing control an accessible name and, in most cases, a visible label programmatically associated with it. Keep the label available while people enter data; a placeholder disappears and can leave users unsure what the field asks for. section 6.7 section 6.1
Clear labels help people complete forms, including users of assistive technology and people with cognitive disabilities.
- Describe the control’s purpose clearly; add instructions when the label alone cannot explain a required format or other constraint. section 6.7
- Do not use a placeholder as the only label: its disappearance can make a field harder to understand while completing the form. section 6.1
Listing 6.1 A form markup with a number of accessibility concerns
<p>
<form action="..." method="post" novalidate>
<div class="form-row">
<input name="name" type="text" placeholder="Owner's Name" /> #A
</div>
<div class="form-row" class="error"> #B
<input name="email" type="text" placeholder="Owner's Email" />
</div>
<div class="form-row">
<input name="breed" type="text" placeholder="Dog's breed" />
</div>
<div class="form-row">
<input name="age" type="text" placeholder="Dog's age" /> #C
</div>
<div class="form-row">
<input name="complaint"
type="text"
placeholder="What is the complaint?" />
</div>
<!-- Submit -->
<div class=”primary-button” id="btn-submit"> #D
Go
</div>
<div class=”primary-button” id="btn-reset">
Reset
</div>
</form>
</p>The example markup uses placeholders instead of labels for owner name, email, dog breed, age, and complaint fields. section 6.1
