re: Proper Coding for Yes/No Questions

Try...

Are you smart?
<input type="radio" name="answer" id="smartYes" /><label
for="smartYes">Yes</label>
<input type="radio" name="answer" id="smartNo" /><label
for="smartNo">No</label>

or...
Are you smart?
<label><input type="radio" name="answer" id="smartYes" />Yes</label>
<label><input type="radio" name="answer" id="smartNo" />No</label>

In my testing, screen readers expect that the label for a radio button will
follow the button itself.  Furthermore, the screen reader (at least JAWs,
which I used to test this most recently) looks to the left of the first
radio input to provide a label for the radio group that is defined by a
common name attribute.  If you put the label for the first radio button to
the left of the first button, it becomes the label for the whole group and
is announced for each item.

If you really want confusion, get the radio buttons to work in JAWS, and
then add a comment containing <label> in the html above the radio group.  I
tried this inadvertently with JAWS 4.01, and the results suggest that JAWS
looks inside of the comments, messing up the spoken output.

Not the end of the world, but worth knowing about if you test possible
solutions by commenting out code.

AWK


On 3/5/02 11:57 AM,  RUST Randal (RRust@COVANSYS.com) wrote:

> I have several forms with simple "yes/no" questions on them.  I need to use
> radio buttons for the selections.
> 
> Is the following code correct for accessibility?
> 
> ----------
> 
> <label for="smart">Are you smart?</label>
> <label for="smartYes">Yes</label><input type="radio" id="smartYes" />
> <label for="smartNo">No</label><input type="radio" id="smartNo" />
> 
> ----------
> 
> Randal Rust
> Covansys, Inc.
> Columbus, OH
> 

-- 
Andrew Kirkpatrick, Technical Project Coordinator
CPB/WGBH National Center for Accessible Media
125 Western Ave.
Boston, MA  02134
E-mail: andrew_kirkpatrick@wgbh.org
Web site: ncam.wgbh.org

617-300-4420 (direct voice/FAX)
617-300-3400 (main NCAM)
617-300-2489 (TTY)

WGBH enriches people's lives through programs and services that educate,
inspire, and entertain, fostering citizenship and culture, the joy of
learning, and the power of diverse perspectives.


------ End of Forwarded Message

Received on Tuesday, 5 March 2002 13:13:24 UTC