---
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
元素提供monospace
的font-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
元素赋予green
的color
属性。
testString: 'assert(($("body").css("color") === "rgb(0, 128, 0)"), "Give your body
element the color
property of green
.");'
- text: 为body
元素提供monospace
的font-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
## Solution
```js
// solution required
```