2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
id: bad87fee1348bd9aedf08736
|
|
|
|
title: Style the HTML Body Element
|
|
|
|
challengeType: 0
|
|
|
|
videoUrl: 'https://scrimba.com/c/cB77PHW'
|
2019-07-31 11:32:23 -07:00
|
|
|
forumTopicId: 18313
|
2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
|
|
|
<section id='description'>
|
|
|
|
Now let's start fresh and talk about CSS inheritance.
|
|
|
|
Every HTML page has a <code>body</code> element.
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id='instructions'>
|
|
|
|
We can prove that the <code>body</code> element exists here by giving it a <code>background-color</code> of black.
|
|
|
|
We can do this by adding the following to our <code>style</code> element:
|
2019-05-14 01:11:58 -07:00
|
|
|
|
|
|
|
```css
|
|
|
|
body {
|
|
|
|
background-color: black;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-09-30 23:01:58 +01:00
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
2018-10-04 14:37:37 +01:00
|
|
|
tests:
|
2019-11-20 06:45:19 -08:00
|
|
|
- text: Your <code>body</code> element should have the <code>background-color</code> of black.
|
2019-07-24 02:50:51 -07:00
|
|
|
testString: assert($("body").css("background-color") === "rgb(0, 0, 0)");
|
2019-11-20 06:45:19 -08:00
|
|
|
- text: Your CSS rule should be properly formatted with both opening and closing curly brackets.
|
2019-07-24 02:50:51 -07:00
|
|
|
testString: assert(code.match(/<style>\s*body\s*\{\s*background.*\s*:\s*.*;\s*\}\s*<\/style>/i));
|
2019-11-20 06:45:19 -08:00
|
|
|
- text: Your CSS rule should end with a semi-colon.
|
2019-07-24 02:50:51 -07:00
|
|
|
testString: assert(code.match(/<style>\s*body\s*\{\s*background.*\s*:\s*.*;\s*\}\s*<\/style>/i));
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
```html
|
|
|
|
<style>
|
|
|
|
|
|
|
|
</style>
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
2019-04-22 01:57:43 -04:00
|
|
|
```html
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
background-color: black;
|
|
|
|
}
|
|
|
|
</style>
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
2019-07-18 08:24:12 -07:00
|
|
|
|
2018-09-30 23:01:58 +01:00
|
|
|
</section>
|