You are here: Associating labels with form controls « HTML « IT news, forums, messages
Associating labels with form controls

Posted by JWL on 10/31/06 17:07

Hi

I read that it's good accessibility practice to link form labels and
controls like this:

<label>Your name: <input name="name" id="name" type="text"></label>

or this:

<p><label for="name">Your name:</label><br>
<input name="name" id="name" type="text"></p>

What I don't understand is how you do this for radio buttons, e.g.:

<p>
<label for="car">Do you own a car?</label><br>
<input name="car" id="car" type="radio" value="Yes" class="radio"> Yes
<input name="car" id="car" type="radio" value="No" class="radio"> No
</p> ~~~~~~~~

or:

<p>
Do you own a car?<br>
<label><input name="car" type="radio" value="Yes" class="radio">
Yes</label>
<label><input name="car" type="radio" value="No" class="radio">
No</label>
</p>

The first example is incorrect because you can't have the same ID on two
elements. And the second example does not link the question, "Do you
have a car?" with the Yes/No controls (although Yes and No labels are
linked to the controls).

What is the correct approach here?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация