--- id: bad87fed1348bd9aede07836 title: Give a Background Color to a div Element challengeType: 0 videoUrl: 'https://scrimba.com/c/cdRKMCk' forumTopicId: 18190 dashedName: give-a-background-color-to-a-div-element --- # --description-- You can set an element's background color with the `background-color` property. For example, if you wanted an element's background color to be `green`, you'd put this within your `style` element: ```css .green-background { background-color: green; } ``` # --instructions-- Create a class called `silver-background` with the `background-color` of `silver`. Assign this class to your `div` element. # --hints-- Your `div` element should have the class `silver-background`. ```js assert.isTrue(document.querySelector('div').classList.contains('silver-background')); ``` Your `div` element should have a silver background. ```js const div = document.querySelector('div'); const backgroundColor = window.getComputedStyle(div)['background-color']; assert.strictEqual(backgroundColor, 'rgb(192, 192, 192)'); ``` A class named `silver-background` should be defined within the `style` element and the value of `silver` should be assigned to the `background-color` property. ```js assert.match(__helpers.removeHtmlComments(code), /\.silver-background\s*{\s*background-color\s*:\s*silver\s*;?\s*}/); ``` # --seed-- ## --seed-contents-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


``` # --solutions-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```