W3C home > Mailing lists > Public > www-html@w3.org > September 2005

Re: Form elements discrepancy

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Sat, 01 Oct 2005 09:47:43 +1000
Message-ID: <433DCE9F.10609@lachy.id.au>
To: Ming Teo <ming@staff.highway1.com.au>
CC: W3C HTML List <www-html@w3.org>

Ming Teo wrote:
> I had a concern regarding the use of checkboxes and radio buttons. Firstly, as 
> every form element should have a label with attribute for="form_element", and 
> every input thus has a name with attribute name="form_element", the use of 
> checkboxes and radio buttons fails.

The for attribute refers to the value of an id attribute, not a name 
attribute.

> <label for="choose">First Option</label> <input type="radio" name="choose" 
> value="First Option" />
> <label for="choose">Second Option</label> <input type="radio" name="choose" 
> value="Second Option" />

That should be something like this:

<label for="choose-first">First Option</label>
   <input type="radio" name="choose" id="choose-first" value="First 
Option" />
<label for="choose-second">Second Option</label>
   <input type="radio" name="choose" id="choose-second" value="Second 
Option" />

-- 
Lachlan Hunt
http://lachy.id.au/
Received on Friday, 30 September 2005 23:48:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:16:04 GMT