Re: title attributes on links

Hi, Harry and all.

The code that you propose does not use a <label> to identify the <input> 
(there is no text inside the <label>, apart from the "value" that is not 
valid to give the control a name).

However, the following code does exactly the same without a visual 
label, and without the need of a title attribute:

<label for="tx-search" class="visually-hidden">Search text</label>
<input id="tx-search" type="text" value="" />
<button type="submit">Search</button>

.visually-hidden {
   position: absolute !important;
   clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
   clip: rect(1px, 1px, 1px, 1px);
   padding:0 !important;
   border:0 !important;
   height: 1px !important;
   width: 1px !important;
   overflow: hidden;
}


So, my concerns are:

- Why the title is GOOD for form controls and BAD for images?
- Is it anywhere in the spec that the title attribute can convey the 
accessible name for form controls but not for images?
- If this rule applies only to form controls, why is it allowed for them 
and not for other elements?
- If this rule applies to any element except images, why are images an 
exception?
- Do you consider this behaviour is consistent?

I already know what WCAG says, what I would like to clarify is why the 
title attribute works differently for different elements and where the 
specs define the difference.

Regards,
Ramón.


Harry wrote:

> I agree that there are situations where a visual label element is not 
> appropriate.
> 
> However, instead of  <input type=text title=search> 
> <button>search</search> (your example), why not use <label><input 
> type="text" id="search" value="search"></label><button>search</button>?

Received on Monday, 28 May 2012 11:22:23 UTC