Skip to content
easeweb
Search topics

Form field labels and hints only in a title tooltip

A gift card form puts each box's name, or the number of digits it takes, in a title attribute, which the browser shows only while a mouse pointer rests on the box.

WCAG 2.2
SC 3.3.2A
Required by
Section 508 · EN 301 549 (EU)
Broken title="Gift card number"
The accessibility problem illustrated: Motor:Which box is the card number?
01

The problem

Keyboard and touch users see empty boxes, with no words to say which is which or how many digits each one takes.

02

Try it

Tab into each gift card box: can you tell what it wants? Then rest the mouse on it.

  • Broken 1: nothing on screen names the boxes. Below the form, compare what a screen reader hears with what you can see. On a phone, tap a box.

  • Broken 2: the labels are printed, but how many digits each box takes is still only in its tooltip.

  • Apply a fix. Tab through again: is every word the screen reader says now on screen?

Broken Can you fix this?

Gift card

Screen reader says:

(Tab to a box)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Print each label and format on screen, in a label element or in a hint tied on with aria-describedby.

  1. 1Every field has its label printed on screen, not only in a title.
  2. 2A format or instruction a field needs is printed too, in the label or beside it.
  3. 3Leave no words in a title that the screen doesn't show.
Before

A title as the only label

<form class="gift-card">  <h2>Gift card</h2>  <input name="card" inputmode="numeric" title="Gift card number">  <input name="pin" inputmode="numeric" title="PIN">  <button type="submit">Apply</button></form>
After

A label and a hint under it

<form class="gift-card">  <h2>Gift card</h2>  <label for="card">Gift card number</label>  <p id="card-hint" class="hint">16 digits</p>  <input id="card" name="card" inputmode="numeric" aria-describedby="card-hint">  <label for="pin">PIN</label>  <p id="pin-hint" class="hint">4 digits</p>  <input id="pin" name="pin" inputmode="numeric" aria-describedby="pin-hint">  <button type="submit">Apply</button></form>

Easily confused
04

Design ideas

A format can sit anywhere on the field, as long as it is there before typing.

Four ways to show that the gift card number takes 16 digits. Tab into each field and type a few digits, then try the same on a phone: two show the format before you type, and two keep it back until you hover or get it wrong.

In the design file

  • Each field three ways: empty, part-filled and filled, with its format still on screen in all three.
  • Put the format on the field or right beside it, never only behind an icon.
  • Write the hint’s contrast ratio beside its colour, at least 4.5:1 for text this size.
  • Use the same words for the format before typing as in the error message.

Passes

  • 16 digits
    A format pill inside the field A soft pill at the field’s end says “16 digits”, #4a4541 on #f1ede9 at 8.13:1. It is there at rest, stays while digits go in and once the field is full, and needs no extra line under the field.
  • 0 of 16 digits
    A count that fills as you type Under the field’s end, “0 of 16 digits” in #5c5650 at 7.24:1, counting up as digits go in. The format is on screen before typing, and the count shows how many are left; it is read with the field, not on every key.

Fails

  • 16 digits
    An ⓘ icon that shows the format on hoverWCAG 3.3.2 A small ⓘ after the label, #5c5650 at 7.24:1, opens a dark card saying “16 digits” while the pointer rests on it. Tab never reaches the icon, so with a keyboard the field is just its label.
  • The format shown only after a wrong tryWCAG 3.3.2 At rest the field says nothing about digits. Type a few digits, fewer than 16, and leave it, and a red line appears, “Enter all 16 digits”, #b3261e at 6.54:1: the rule was there from the start, but the screen shows it only once someone has broken it.
05

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Touch, Screen reader, Zoom

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared field component changes.

How screen readers handle aria-describedby, title (no label) and title (with a label)

Limits

This is a starting pattern, not a guarantee for every application. It covers labels and instructions a field needs in order to be filled in. Help that explains where to find something, such as which number on the card is the PIN, is a separate Level AAA topic, "Forms offer help beside the fields that need it", which has no guide yet. Fields added by payment iframes, third-party widgets or content editors need the same check. Test the complete journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work