# Inherit Styles from the Body Element

**URL:** <https://forum.freecodecamp.org/t/inherit-styles-from-the-body-element/147120>\
**Category:** General\
**Created:** [September 10, 2017, 12:30pm UTC](https://forum.freecodecamp.org/t/inherit-styles-from-the-body-element/147120 "2017-09-10T12:30:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![herambh](https://avatars.discourse-cdn.com/v4/letter/h/43a26b/32.png) [@herambh](https://forum.freecodecamp.org/u/herambh)\
**Post date:** [September 10, 2017, 12:30pm UTC](https://forum.freecodecamp.org/t/inherit-styles-from-the-body-element/147120/1 "2017-09-10T12:30:37Z")

</div>

**Tell us what’s happening:**

**Your code so far**

```auto
<style>
  body {
    background-color: black;
  }
  .green {
    
  }
</style>
<h1 color="green">hello world</h1>

```

**Your browser information:**

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36`.

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/inherit-styles-from-the-body-element](https://www.freecodecamp.org/challenges/inherit-styles-from-the-body-element)

---

<div class="post-metadata">

**Author:** ![CallMeFrank](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/callmefrank/32/69242_2.png) [@CallMeFrank](https://forum.freecodecamp.org/u/CallMeFrank)\
**Post date:** [September 10, 2017, 2:08pm UTC](https://forum.freecodecamp.org/t/inherit-styles-from-the-body-element/147120/2 "2017-09-10T14:08:06Z")

</div>

Hi.  
In this challange main thing is “inherit styles”.  
Inheritance means in this case - `body` is parent of `h1` and `h1` can take styles like `color, background, font-size, font-family`. [Check more info here](https://developer.mozilla.org/ru/docs/Web/CSS/inheritance)  
Other words if you define `
body {
color: red;
}
` then `
h1` will take `color: red;` automatically.  
But if you define `
h1{
background-color:green;
}
`then `body` will not accept style rule `background-color: green;`.It will be defaul `#fff`

So lets take a look at your code. We need make `h1` color: green but not define inline style like `h1 color=“green”` .  
So we can define `
body{
font-family: Monospace;
color: green;}
` for `body`. Then `h1` will take style `font-family:Monospace;`. and `color: green;`

Feel free to ask a questions.  
Best rigards.

---

<div class="post-metadata">

**Author:** ![Debbie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/debbie/32/98742_2.png) [@Debbie](https://forum.freecodecamp.org/u/Debbie)\
**Post date:** [December 4, 2018, 3:53pm UTC](https://forum.freecodecamp.org/t/inherit-styles-from-the-body-element/147120/3 "2018-12-04T15:53:14Z")

</div>

Thank you for explaining the formula, it was extremely helpful.It cleared up a lot for me. 😄

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:16pm UTC](https://forum.freecodecamp.org/t/inherit-styles-from-the-body-element/147120/4 "2021-01-17T20:16:22Z")

</div>

Closed on January 17, 2021, 8:16pm UTC


