--- id: 587d778b367417b2b2512aa7 challengeType: 0 videoUrl: 'https://scrimba.com/c/cVJVefw' forumTopicId: 301030 localeTitle: 将单选按钮包裹在 fieldset 元素中以获得更好的可访问性 --- ## Description
下一个表单主题与单选按钮的可访问性有关。在上一个挑战中,单选按钮含有一个拥有for属性的label标签,for属性指向相关选项的id。然而单选按钮通常成组出现,用户必须其中选择一项。本次挑战介绍一种可以语义化呈现单选按钮组的方法。 使用fieldset标签将单选按钮组包含在里面就可以实现这个目的,通常还会使用legend标签来为单选按钮组提供文字说明。屏幕阅读器也可以朗读这些文字。 当选项的含义很明确时,如:性别选择,fieldset标签与legend标签就可以省略。这时,使用含有for属性的label标签就足够了。 举个例子: ```html
Choose one of these three items:

```
## Instructions
当用户使用邮件注册时,Camper Cat 想知道他们的忍者等级。通过上一个挑战的学习,Camper Cat 创建了一组单选按钮,并为每个选项的label标签添加了for属性,但是 Camper Cat 的代码依然需要你的帮助。请将包含单选按钮组的div标签替换为fieldset标签;将p标签替换为legend标签。
## Tests
```yml tests: - text: '你的代码应该使用 1 个fieldset标签包含单选按钮组。' testString: assert($('fieldset').length == 1); - text: '确保fieldset标签是闭合的。' testString: assert(code.match(/<\/fieldset>/g) && code.match(/<\/fieldset>/g).length === code.match(/
/g).length); - text: '你的代码应该有 1 个包含询问用户忍者等级文字的legend标签。' testString: assert($('legend').length == 1); - text: '你的代码不应该含有div标签。' testString: assert($('div').length == 0); - text: '你的代码不应该有包含询问用户忍者等级文字的p标签。' testString: assert($('p').length == 4); ```
## Challenge Seed
```html

Deep Thoughts with Master Camper Cat

Sign up to receive Camper Cat's blog posts by email here!

What level ninja are you?



The Garfield Files: Lasagna as Training Fuel?

The internet is littered with varying opinions on nutritional paradigms, from catnip paleo to hairball cleanses. But let's turn our attention to an often overlooked fitness fuel, and examine the protein-carb-NOM trifecta that is lasagna...

Defeating your Foe: the Red Dot is Ours!

Felines the world over have been waging war on the most persistent of foes. This red nemesis combines both cunning stealth and lightning speed. But chin up, fellow fighters, our time for victory may soon be near...

Is Chuck Norris a Cat Person?

Chuck Norris is widely regarded as the premier martial artist on the planet, and it's a complete coincidence anyone who disagrees with this fact mysteriously disappears soon after. But the real question is, is he a cat person?...

```
## Solution
```html // solution required ```