Inherit Styles from the Body Element
Now we've proven that every HTML page has a body
element, and that its body
element can also be styled with CSS.
Remember, you can style your body
element just like any other HTML element, and all your other elements will inherit your body
element's styles.
First, create an h1
element with the text Hello World
.
Then, let's give all elements on your page the color of green
by adding color: green;
to your body
element's style declaration.
Finally, give your body
element the font-family of monospace
by adding font-family: monospace;
to your body
element's style declaration.
Tests
- Waiting: 1. You should create an
h1
element. - Waiting: 2. Your
h1
element should have the textHello World
. - Waiting: 3. Your
h1
element should have a closing tag. - Waiting: 4. Your
body
element should have thecolor
property ofgreen
. - Waiting: 5. Your
body
element should have thefont-family
property ofmonospace
. - Waiting: 6. Your
h1
element should inherit the fontmonospace
from yourbody
element. - Waiting: 7. Your
h1
element should inherit the colorgreen
from yourbody
element.
/** * Your test output will go here */