--- id: bad87fee1348bd9aedf08746 title: Inherit Styles from the Body Element challengeType: 0 videoUrl: '' localeTitle: 从Body元素继承样式 --- ## Description
现在我们已经证明每个HTML页面都有一个body元素,并且它的body元素也可以用CSS设置样式。记住,你可以风格你body元素,就像任何其他HTML元素,和所有其他元素将继承你的body元素的样式。
## Instructions
首先,创建一个h1与文本元素Hello World然后,让我们给您的网页上的所有元素的颜色green中加入color: green;你的body元素的风格声明。最后,通过添加font-family: monospace; ,为你的body元素提供monospacefont-family: monospace;你的body元素的风格声明。
## Tests
```yml tests: - text: 创建一个h1元素。 testString: 'assert(($("h1").length > 0), "Create an h1 element.");' - text: 你的h1元素应该有文本Hello World 。 testString: 'assert(($("h1").length > 0 && $("h1").text().match(/hello world/i)), "Your h1 element should have the text Hello World.");' - text: 确保您的h1元素具有结束标记。 testString: 'assert(code.match(/<\/h1>/g) && code.match(/

/g).length === code.match(/

h1 element has a closing tag.");' - text: 为你的body元素赋予greencolor属性。 testString: 'assert(($("body").css("color") === "rgb(0, 128, 0)"), "Give your body element the color property of green.");' - text: 为body元素提供monospacefont-family属性。 testString: 'assert(($("body").css("font-family").match(/monospace/i)), "Give your body element the font-family property of monospace.");' - text: 你的h1元素应该从你的body元素继承font monospace 。 testString: 'assert(($("h1").length > 0 && $("h1").css("font-family").match(/monospace/i)), "Your h1 element should inherit the font monospace from your body element.");' - text: 您的h1元素应该从您的body元素继承绿色。 testString: 'assert(($("h1").length > 0 && $("h1").css("color") === "rgb(0, 128, 0)"), "Your h1 element should inherit the color green from your body element.");' ```

## Challenge Seed
```html ```
## Solution
```js // solution required ```