RE: Radio buttons id's and labels

The example there, as a fragment of XHTML stripped of accesskeys and other
features, is something like

<fieldset>
  <legend>Choice of role</legend>
    <input type="radio" name="choices" value="1" />Option 1
    <input type="radio" name="choices" value="2" />Option 2
</fieldset>

An HTML browser that doesn't recognise this will present the text "Choice of
role" as a paragraph on its own before the radio buttons, so most assistive
technologies should render it as text even if they don't associate it in any
more meaningful way.

Using an XML browser that can expand/collapse the tree (most of those I have
seen) the legend will appear as one of the things in the fieldset (the
others being radio buttons, and possibly labels as well), and it can opf
course be controlled by CSS as well.

If anyone can test this it would be useful information.

Cheers

Charles McCN

On Wed, 28 Jun 2000, Al Gilman wrote:

  The theoretical answer from HTML 4 is that the "Choice of role" is the
  LEGEND of a FIELDSET enclosing the set of radio buttons.
  
  What I don't fully know is how that plays in current browsers and assistive
  technology.
  
  For more information you could start at
  
   http://www.htmlhelp.com/reference/html40/forms/legend.html
  
  Al
  
  At 01:44 PM 2000-06-28 -0400, Bruce Bailey wrote:
  >Dear Nancy,
  >I was hoping someone more technical than I would volunteer, but here's my
  >best guess...
  >
  >(1)  I too tend to use select form -- it's easier to navigate w/ a screen
  >reader.  It also eliminates the particular problem you are having.
  >
  >(2)  Yes, you want all your radio buttons to have the same NAME value (or it
  >doesn't work right), but there is no compelling reason why ID has to be
  >equivalent to NAME, so your example code could be:
  >
  > <label for="role">Choice of role</label>
  > <input name="role" id="role1" value="Mentor only" type="radio">
  >	a Mentor only
  > <input name="role" id="role2" value="Mentor or a Lead Mentor" type="radio">
  >	a Mentor or a lead Mentor
  >
  >Haven't tried this, so I can't say for sure it works.  (The forms I have
  >done that use radio buttons I haven't bothered with ID values.)  ID is
  >something that (in theory only?) gets picked up by the screen reader or
  >other UA.  I am not sure if it can have spaces, or is even used in practice.
  >For example, "role value 1 of 2" might be a better choice.
  >
  >Please let me know (on or off the list) if this works or not.
  >Cheers,
  >Bruce
  >
  >> -----Original Message-----
  >> From: w3c-wai-ig-request@w3.org [mailto:w3c-wai-ig-request@w3.org]On
  >> Behalf Of Massey, Nancy
  >> Sent: Wednesday, June 28, 2000 12:30 PM
  >> To: w3c-wai-ig@w3.org
  >> Subject: Re: Radio buttons id's and labels
  >>
  >>
  >>
  >> >I'm trying to achieve AA status for a form and I'm stuck on how to do
  >> >radio fields (I realise I could use a select form but the client wants a
  >> >radio button):
  >> >
  >> >   <label for="role">Choice of role</label>
  >> >   <input name="role" id="role" value="Mentor only" type="radio" /> a
  >> > Mentor only
  >> >   <input name="role" id="role" value="Mentor or a Lead Mentor"
  >> > type="radio" /> a Mentor or a Lead Mentor
  >> >
  >> >The above is invalid as you can't have two id's which are the same... so
  >> >how does one do this?
  >>
  >>
  >> While working on a site that has over 700 documents, I encountered this
  >> problem about the same time that Chris posted this message.
  >> Except for this
  >> one issue the site I am working on can achieve AA status. This is also a
  >> problem when using the validator.w3.org. The site will not
  >> validate at HTML
  >> 4.01 - can not use two or more id's with the same name.
  >>
  >> So I ask the question again, has anyone been able to solve this problem?
  >>
  >> thanks,
  >>
  >>
  >> Nancy Massey
  >> <http://www.masseynet.com/>
  >>
  > 
  

--
Charles McCathieNevile    mailto:charles@w3.org    phone: +61 (0) 409 134 136
W3C Web Accessibility Initiative                      http://www.w3.org/WAI
Location: I-cubed, 110 Victoria Street, Carlton VIC 3053
Postal: GPO Box 2476V, Melbourne 3001,  Australia 

Received on Sunday, 2 July 2000 08:42:02 UTC