2021-06-15 14:21:20 +00:00
---
id: bad87fee1348bd9aedf08746
2021-06-27 18:21:13 +00:00
title: Herdar estilos do elemento body
2021-06-15 14:21:20 +00:00
challengeType: 0
videoUrl: 'https://scrimba.com/c/c9bmdtR'
forumTopicId: 18204
dashedName: inherit-styles-from-the-body-element
---
# --description--
2021-06-27 18:21:13 +00:00
No desafio anterior, provamos que cada página HTML tem um elemento `body` , e que o elemento `body` também pode ser estilizado com CSS.
2021-06-15 14:21:20 +00:00
2021-06-27 18:21:13 +00:00
Lembre-se de que você pode definir o estilo do elemento `body` como qualquer outro elemento HTML, e todos os outros elementos herdarão os estilos do elemento `body` .
2021-06-15 14:21:20 +00:00
# --instructions--
2021-06-27 18:21:13 +00:00
Primeiro, crie um elemento `h1` com o texto `Hello World`
2021-06-15 14:21:20 +00:00
2021-06-27 18:21:13 +00:00
Então, vamos dar a todos os elementos da página a cor `green` adicionando `color: green;` à declaração de estilo do elemento `body` .
2021-06-15 14:21:20 +00:00
2021-06-27 18:21:13 +00:00
Por fim, dê ao elemento `body` a tipografia `monospace` adicionando `font-family: monospace;` à declaração de estilo do elemento `body` .
2021-06-15 14:21:20 +00:00
# --hints--
2021-06-27 18:21:13 +00:00
Você deve criar um elemento `h1` .
2021-06-15 14:21:20 +00:00
```js
assert($('h1').length > 0);
```
2021-06-27 18:21:13 +00:00
O elemento `h1` deve conter o texto `Hello World` .
2021-06-15 14:21:20 +00:00
```js
assert(
$('h1').length > 0 & &
$('h1')
.text()
.match(/hello world/i)
);
```
2021-06-27 18:21:13 +00:00
O elemento `h1` deve ter uma tag de fechamento.
2021-06-15 14:21:20 +00:00
```js
assert(
code.match(/< \/h1 > /g) &&
code.match(/< h1 / g ) & &
code.match(/< \/h1 > /g).length === code.match(/< h1 / g ). length
);
```
2021-06-27 18:21:13 +00:00
O elemento `body` deve ter a propriedade `color` com o valor `green` .
2021-06-15 14:21:20 +00:00
```js
assert($('body').css('color') === 'rgb(0, 128, 0)');
```
2021-06-27 18:21:13 +00:00
O elemento `body` deve ter a propriedade `font-family` com o valor `monospace` .
2021-06-15 14:21:20 +00:00
```js
assert(
$('body')
.css('font-family')
.match(/monospace/i)
);
```
2021-06-27 18:21:13 +00:00
O elemento `h1` deve herdar a fonte `monospace` do elemento `body` .
2021-06-15 14:21:20 +00:00
```js
assert(
$('h1').length > 0 & &
$('h1')
.css('font-family')
.match(/monospace/i)
);
```
2021-06-27 18:21:13 +00:00
O elemento `h1` deve herdar a cor verde do elemento `body` .
2021-06-15 14:21:20 +00:00
```js
assert($('h1').length > 0 & & $('h1').css('color') === 'rgb(0, 128, 0)');
```
# --seed--
## --seed-contents--
```html
< style >
body {
background-color: black;
}
< / style >
```
# --solutions--
```html
< style >
body {
background-color: black;
font-family: monospace;
color: green;
}
< / style >
< h1 > Hello World!< / h1 >
```