2018-10-04 14:37:37 +01:00
---
id: bad87fee1348bd9aedf08746
title: Inherit Styles from the Body Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/c9bmdtR'
2019-07-31 11:32:23 -07:00
forumTopicId: 18204
2018-10-04 14:37:37 +01:00
---
## Description
< section id = 'description' >
Now we've proven that every HTML page has a < code > body< / code > element, and that its < code > body< / code > element can also be styled with CSS.
Remember, you can style your < code > body< / code > element just like any other HTML element, and all your other elements will inherit your < code > body< / code > element's styles.
< / section >
## Instructions
< section id = 'instructions' >
First, create a < code > h1< / code > element with the text < code > Hello World< / code >
Then, let's give all elements on your page the color of < code > green< / code > by adding < code > color: green;< / code > to your < code > body< / code > element's style declaration.
Finally, give your < code > body< / code > element the font-family of < code > monospace< / code > by adding < code > font-family: monospace;< / code > to your < code > body< / code > element's style declaration.
< / section >
## Tests
< section id = 'tests' >
```yml
tests:
2019-11-20 06:45:19 -08:00
- text: You should create an < code > h1</ code > element.
2019-07-24 02:50:51 -07:00
testString: assert(($("h1").length > 0));
2018-10-04 14:37:37 +01:00
- text: Your < code > h1</ code > element should have the text < code > Hello World</ code > .
2019-07-24 02:50:51 -07:00
testString: assert(($("h1").length > 0 & & $("h1").text().match(/hello world/i)));
2019-11-20 06:45:19 -08:00
- text: Your < code > h1</ code > element should have a closing tag.
2019-07-24 02:50:51 -07:00
testString: assert(code.match(/< \/h1 > /g) && code.match(/< h1 / g ) && code . match (/< \/h1 > /g).length === code.match(/< h1 / g ). length );
2019-11-20 06:45:19 -08:00
- text: Your < code > body</ code > element should have the < code > color</ code > property of < code > green</ code > .
2019-07-24 02:50:51 -07:00
testString: assert(($("body").css("color") === "rgb(0, 128, 0)"));
2019-11-20 06:45:19 -08:00
- text: Your < code > body</ code > element should have the < code > font-family</ code > property of < code > monospace</ code > .
2019-07-24 02:50:51 -07:00
testString: assert(($("body").css("font-family").match(/monospace/i)));
2018-10-04 14:37:37 +01:00
- text: Your < code > h1</ code > element should inherit the font < code > monospace</ code > from your < code > body</ code > element.
2019-07-24 02:50:51 -07:00
testString: assert(($("h1").length > 0 & & $("h1").css("font-family").match(/monospace/i)));
2018-10-04 14:37:37 +01:00
- text: Your < code > h1</ code > element should inherit the color green from your < code > body</ code > element.
2019-07-24 02:50:51 -07:00
testString: assert(($("h1").length > 0 & & $("h1").css("color") === "rgb(0, 128, 0)"));
2018-10-04 14:37:37 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'html-seed' >
```html
< style >
body {
background-color: black;
}
< / style >
```
< / div >
< / section >
## Solution
< section id = 'solution' >
2019-04-22 01:57:43 -04:00
```html
< style >
body {
background-color: black;
font-family: monospace;
color: green;
}
< / style >
< h1 > Hello World!< / h1 >
2018-10-04 14:37:37 +01:00
```
2019-07-18 08:24:12 -07:00
2018-10-04 14:37:37 +01:00
< / section >