WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Do screen readers read title attirbute if there is no label tag on form elements?


From: Jukka K. Korpela
Date: Apr 20, 2011 3:54AM

Angela French wrote:

> I just came upon the instruction below and wondering if part of it is
> true:

It is partly true, but I think the most essential question here is one that
hasn't been asked yet.

> The instructions:
> HTML Form Inputs Using the Title Attribute
> In some cases, it is visually impractical to use a form label. When
> fields have no visual labels the title attribute provides information
> about the fields. Assistive technology looks for the <label> element,
> but if it isn't provided, they will read the title attribute.
> <input type="text" name="num2" title="Enter your 3 digit phone exchange"
> />
> <input type="text" name="num3" title="Enter the last 4 digits of your
> phone number" />

The example suggests is about a phone number divided into two fields.
Typically, cases where "it is visually impractical to use a form label" are
of this type. So, assuming that you are in control of the markup and the
processing of form data, wouldn't it be better to use a single field? The
problem would vanish in a puff of logic, and you could write:

<label for="phone">Your phone number:</label>
<input type="tel" id="phone" name="phone">

This makes typing the number easier and more natural, and it lets the user
copy and paste the number, or maybe accept a value previously entered in a
field with the same name. Moreover, you can use type="tel" (as per HTML5
drafts), thereby letting browsers implement the field in an intelligent way,
designed for phone number input - support to this is limited but increasing,
and it may include specific input methods (e.g., a virtual keyboard suitable
for phone number input) as well as checking the format of the input. And on
non-supporting browsers, the input element degrades gracefully to an
old-fashioned text input box.

For other types of data, the situation might not be equally clearcut, but in
general, data items such as phone numbers or dates should not be split to
separate fields corresponding to their components. One reason to this is
that you can normally write a natural label for the item, but labelling the
components separately would get awkward.

> Is the following true? " Assistive technology looks for the <label>
> element, but if it isn't provided, they will read the title
> attribute."

That applies to some assistive technologies, at least in some situations. I
wouldn't bet on the universality of such behavior.

Yucca, http://www.cs.tut.fi/~jkorpela/