开发者

accessibility - label attributes for radiobuttons

开发者 https://www.devze.com 2023-01-16 19:19 出处:网络
I have a form which contains a \'gender\' label and two radio buttons\'male\' and \'female\'. How can I put \'label for\' in this particular scenario ?

I have a form which contains a 'gender' label and two radio buttons'male' and 'female'. How can I put 'label for' in this particular scenario ?

<label for="username">User Name</label> <input开发者_StackOverflow type ="text" id="username" />
<label for="?">Gender</label>
    <label for="male"><input type="radio" id="male" value="male" /> </label>
    <label for="female"><input type="radio" id="female" value="female" /> </label>


You do not need a label around Gender, just the male/female ones you have associated with the individual inputs. You could classify Gender either just with a Heading tag or with a Legend tag and a Fieldset spanned around the input collection.

You do however need to output some text in your male/female labels, perhaps after each input.

0

精彩评论

暂无评论...
验证码 换一张
取 消