Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XHTML-radio button: what's the 'false' value?

Tags:

html

xhtml

radio

I just tried the following HTML :

<input type='radio' checked='checked' name='test' id='r1' />
<input type='radio' checked='' name='test' id='r2' />

which (in my mind's eye) should have the first radio button checked. Turns out browsers will check any radio button with a checked attribute.

Is there a 'false' value, that won't check the button, so my code is consistent?

like image 457
Ben Avatar asked May 30 '11 06:05

Ben


1 Answers

The absence of the checked attribute is the only way you can do this.

Traditionally only the word checked was requried to indicate a checked status (you didn't have to set it to be a value). I think the attributename="value" pattern is for compatibility with standards such as xhtml (which is why browsers ignore the value itself)

like image 73
Martin Booth Avatar answered Nov 01 '22 07:11

Martin Booth