# Give a Background Color to a Div Element not working

**URL:** <https://forum.freecodecamp.org/t/give-a-background-color-to-a-div-element-not-working/166853>\
**Category:** General\
**Created:** [January 5, 2018, 1:59am UTC](https://forum.freecodecamp.org/t/give-a-background-color-to-a-div-element-not-working/166853 "2018-01-05T01:59:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bflan2001](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bflan2001](https://forum.freecodecamp.org/u/bflan2001)\
**Post date:** [January 5, 2018, 1:59am UTC](https://forum.freecodecamp.org/t/give-a-background-color-to-a-div-element-not-working/166853/1 "2018-01-05T01:59:43Z")

</div>

My code works fine, I’ve rewritten it a dozen times, tried variations with and without quotations, etc. but nothing is working to get me through to the next lesson. The example shows the silver background is there, so I can’t figure out what it doesn’t like.

**Your code so far**

```auto
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
 
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
  
  div {background-color: silver}
 

</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#">cat photos</a>.</p>

<a href="#"><img class="smaller-image thick-green-border" alt="A cute orange cat lying on its back. " src="https://bit.ly/fcc-relaxing-cat"></a>

<div class=silver.background>
  <p>Things cats love:</p>
  <ul>
    <li>cat nip</li>
    <li>laser pointers</li>
    <li>lasagna</li>
  </ul>
  <p>Top 3 things cats hate:</p>
  <ol>
    <li>flea treatment</li>
    <li>thunder</li>
    <li>other cats</li>
  </ol>
</div>

<form action="/submit-cat-photo">
  <label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
  <label><input type="radio" name="indoor-outdoor"> Outdoor</label>
  <label><input type="checkbox" name="personality" checked> Loving</label>
  <label><input type="checkbox" name="personality"> Lazy</label>
  <label><input type="checkbox" name="personality"> Energetic</label>
  <input type="text" placeholder="cat photo URL" required>
  <button type="submit">Submit</button>
</form>

```

**Your browser information:**

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

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/give-a-background-color-to-a-div-element](https://www.freecodecamp.org/challenges/give-a-background-color-to-a-div-element)

---

<div class="post-metadata">

**Author:** ![loudigi](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/loudigi/32/74990_2.png) [@loudigi](https://forum.freecodecamp.org/u/loudigi)\
**Post date:** [January 5, 2018, 2:08am UTC](https://forum.freecodecamp.org/t/give-a-background-color-to-a-div-element-not-working/166853/3 "2018-01-05T02:08:33Z")

</div>

Your CSS style is ok, but you won’t need to call out a class in the div that’s in your html body so just remove  
"class=silver.background " from the div. Your CSS will apply that background to all divs.

---

<div class="post-metadata">

**Author:** ![bflan2001](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bflan2001](https://forum.freecodecamp.org/u/bflan2001)\
**Post date:** [January 6, 2018, 2:08am UTC](https://forum.freecodecamp.org/t/give-a-background-color-to-a-div-element-not-working/166853/4 "2018-01-06T02:08:54Z")

</div>

Thank you very much, I was able to figure it out with the help of both replies.

---

<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 16, 2021, 6:00pm UTC](https://forum.freecodecamp.org/t/give-a-background-color-to-a-div-element-not-working/166853/5 "2021-01-16T18:00:00Z")

</div>


