--- id: bad87fee1348bd9aedf08805 title: Use CSS Selectors to Style Elements challengeType: 0 videoUrl: 'https://scrimba.com/c/cJKMBT2' forumTopicId: 18349 --- ## Description
With CSS, there are hundreds of CSS properties that you can use to change the way an element looks on your page. When you entered <h2 style="color: red;">CatPhotoApp</h2>, you were styling that individual h2 element with inline CSS, which stands for Cascading Style Sheets. That's one way to specify the style of an element, but there's a better way to apply CSS. At the top of your code, create a style block like this: ```html ``` Inside that style block, you can create a CSS selector for all h2 elements. For example, if you wanted all h2 elements to be red, you would add a style rule that looks like this: ```html ``` Note that it's important to have both opening and closing curly braces ({ and }) around each element's style rule(s). You also need to make sure that your element's style definition is between the opening and closing style tags. Finally, be sure to add a semicolon to the end of each of your element's style rules.
## Instructions
Delete your h2 element's style attribute, and instead create a CSS style block. Add the necessary CSS to turn all h2 elements blue.
## Tests
```yml tests: - text: The style attribute should be removed from your h2 element. testString: assert(!$("h2").attr("style")); - text: You should create a style element. testString: assert($("style") && $("style").length >= 1); - text: Your h2 element should be blue. testString: assert($("h2").css("color") === "rgb(0, 0, 255)"); - text: Your stylesheet h2 declaration should be valid with a semicolon and closing brace. testString: assert(code.match(/h2\s*\{\s*color\s*:.*;\s*\}/g)); - text: All your style elements should be valid and have closing tags. testString: assert(code.match(/<\/style>/g) && code.match(/<\/style>/g).length === (code.match(//g) || []).length); ```
## Challenge Seed
```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```
## Solution
```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```