Sub topic 4
Hint text, and why placeholders are not labels
This chapter assumes you can write basic HTML forms and know that a label element is tied to an input with for and id. You also need to know how to give an element an id and reference it from an attribute. No JavaScript is needed here.
What hint text is
Hint text is a short piece of persistent text that helps a user fill in a field. It answers questions the label cannot answer in a few words: what format to use, what the limits are, or why you are asking.
- The label says what the field is: "Postcode".
- The hint says how to fill it in: "For example, SW1A 1AA".
The key property is that hint text stays on screen while the user types. That is what separates it from a placeholder, which is the grey text inside an empty input.
Why placeholders fail as labels
The placeholder attribute looks like a space-saving shortcut. A field with only a placeholder has no label, and the problems add up.
- It disappears. As soon as the user types, the text is gone. A user who is interrupted, or who is checking a long form before submitting, cannot see what the field asked for.
- It looks like a value. Placeholder text that is dark enough to read can be mistaken for something already entered. Users skip fields that look filled in, and the form then fails on submit.
- It is usually too faint. Browsers default to a light grey. That grey often fails the WCAG 2.x text contrast minimum of 4.5:1 against a white background. If you darken it to pass, problem 2 gets worse.
- It is unreliable for assistive technology. Browsers may use the placeholder as a fallback accessible name, but support and announcement behavior differ. A visible
labelis the dependable way to name a control. - It is hard to target and click. A label is a clickable target that focuses its input. A placeholder is not. This matters for people with motor impairments, and for radio buttons and checkboxes where the label enlarges a tiny hit area.
- It is cut off. Placeholders do not wrap. In a narrow input, or when text is enlarged, long placeholder text is clipped.
- It adds memory load. Users with short-term memory or attention difficulties must remember the instruction while typing.
Because of these problems, the safe rule is to put the question in the label and any extra guidance in hint text. If you want a placeholder at all, treat it as optional decoration, never as the only place information lives.
The hint text pattern
Put the hint in an ordinary element and connect it to the input with aria-describedby. The attribute takes the id of the element that describes the control.
<label for="postcode">Postcode</label>
<p id="postcode-hint">For example, SW1A 1AA</p>
<input id="postcode" name="postcode" type="text" autocomplete="postal-code" aria-describedby="postcode-hint">Three things are happening here:
- The label gives the control its accessible name, "Postcode".
- The
pelement is visible to everyone, so sighted users can read it before and while they type. aria-describedbymakes a screen reader announce the hint after the name and role, typically something like "Postcode, edit text, For example, SW1A 1AA". The hint is extra detail, so it comes after the essential information.
The visual order also matters. Place the hint between the label and the input, so the reader meets the question, then the help, then the place to answer. This keeps the label and hint together and stops the hint from being confused with an error message that appears below the field.
Referencing more than one description
aria-describedby accepts a space-separated list of ids. The screen reader reads them in the order you list them. This is how a hint and an error message coexist on one field.
<label for="password">Password</label>
<p id="password-hint">Use at least 12 characters. A phrase of several words works well.</p>
<input id="password" name="password" type="password"
autocomplete="new-password" minlength="12" required
aria-describedby="password-hint password-error">
<p id="password-error" hidden></p>When the error appears, your script sets its text and removes hidden. The hint remains in place. Listing the error id from the start is safe, because an empty or hidden element contributes nothing useful, and the reference does not break.
A common mistake is to replace the hint's id with the error's id when validation fails. The user then loses the format guidance at the moment they need it most. Keep both.
What belongs in a hint
Use hint text for information that helps most users complete the field correctly:
- Format examples: "For example, 07700 900123".
- Constraints: "Must be 12 characters or more".
- Reasons: "We only use this to send your receipt".
- Where to find it: "The 8-digit number on the front of your card".
Keep hints short, at one sentence if you can. If a hint needs three paragraphs, the field is probably asking for something confusing, and the problem is better solved by changing the field, splitting it, or linking to a help page near the form.
Do not use hint text for:
- The question itself. That is the label's job.
- Rules the user only learns after failing. State a password rule before the user types, not only in the error.
- Critical warnings. Hints are easy to overlook. Important consequences deserve a callout above the control or a confirmation step.
| Information | Best place |
|---|---|
| What the field is | Visible `label` |
| Format example or limit | Hint text linked by `aria-describedby` |
| What went wrong | Error message, also linked by `aria-describedby` |
| Related question for a group of controls | `legend` inside a `fieldset` |
| Optional visual example | Placeholder, only as a supplement |
Hints on groups
A group of radio buttons or checkboxes shares one question, and that question lives in a legend. A hint for the whole group should attach to the fieldset, not to each option.
<fieldset aria-describedby="contact-hint">
<legend>Preferred contact method</legend>
<p id="contact-hint">We will only use this to reply to your enquiry.</p>
<div>
<input type="radio" id="contact-email" name="contact" value="email">
<label for="contact-email">Email</label>
</div>
<div>
<input type="radio" id="contact-phone" name="contact" value="phone">
<label for="contact-phone">Phone</label>
</div>
</fieldset>Screen readers vary in how they announce a fieldset description. Some read it when the user enters the group, and others only read the legend. Because of that variation, keep the hint short and make sure the legend still makes sense alone.
Where information goes: a decision flow
Edge cases and gotchas
- Placeholders as examples. A placeholder like
[email protected]is acceptable only if the same information is not required elsewhere. If the format matters, repeat it in hint text. aria-labelis not a fix. It names the control for screen readers but gives sighted users nothing. Visible text is the requirement.- Hidden referenced elements. If
aria-describedbypoints to an element hidden withhiddenordisplay: none, assistive technology can still use its text when the element is referenced. That is why the error pattern above works, but it also means you should not reference elements you do not want read. - Do not duplicate text. If the label says "Date of birth" and the hint says "Enter your date of birth", a screen reader says it twice. Make the hint add something: "For example, 27 3 2007".
- Autofill and
autocomplete. A correctautocompletevalue reduces the need for format hints, because the browser fills in a valid value. - Zoom and reflow. Because a hint is normal text in the page, it wraps when text is enlarged. A placeholder clips. This is one more reason for the pattern.
- Floating labels. These shrink a label into the top of the field once the user types. They are a placeholder-style compromise. They keep a label visible, but the shrunken text is small, and they leave no room for a hint. The next chapter's trade-offs apply here too.
Summary
The label names the field. Hint text carries format, limits, and reasons, stays visible, and is linked with aria-describedby. A placeholder, if used, only decorates. Keep hints short, place them between label and input, preserve them when errors appear, and attach group hints to the fieldset.
Exercise
A signup form has an input with only placeholder="Password (min 12 characters)" and no label. Describe how you would fix it, including the markup for the label, the hint, and the connection between them, and name two problems the original design causes.
Show answer
Add a visible label, move the rule into hint text, and link them: <label for="password">Password</label><p id="password-hint">Use at least 12 characters.</p><input id="password" name="password" type="password" autocomplete="new-password" minlength="12" required aria-describedby="password-hint">. The original design causes problems such as the instruction vanishing as soon as the user types, no reliable accessible name or clickable label, and light placeholder text that likely fails the 4.5:1 contrast minimum. When an error is added later, list its id after the hint id in aria-describedby so the hint is kept.