--- id: bad87fee1348bd9aecf08806 title: Use a CSS Class to Style an Element challengeType: 0 videoUrl: https://scrimba.com/c/c2MvDtV forumTopicId: 18337 localeTitle: Используйте селектор класса в CSS для стилизации элемента --- ## Description
Классы - многоразовые стили, которые можно добавить к элементам HTML. Вот пример объявления класса CSS:
<style>
.blue-text {
color: blue;
}
</ style>
Вы можете видеть, что мы создали класс CSS, который назвали blue-text в <style> . Вы можете применить класс к HTML-элементу следующим образом: <h2 class="blue-text">CatPhotoApp</h2> Обратите внимание, что в элементе style CSS имена классов начинаются с точки. В атрибуте класса HTML-элементов имя класса не включает точку.
## Instructions
Внутри элемента style измените селектор h2 на .red-text и обновите значение цвета с blue на red . Задайте вашему элементу h2 атрибут class со значением 'red-text' .
## Tests
```yml tests: - text: Your h2 element should be red. testString: assert($("h2").css("color") === "rgb(255, 0, 0)"); - text: Your h2 element should have the class red-text. testString: assert($("h2").hasClass("red-text")); - text: Your stylesheet should declare a red-text class and have its color set to red. testString: assert(code.match(/\.red-text\s*\{\s*color\s*:\s*red;\s*\}/g)); - text: Do not use inline style declarations like style="color: red" in your h2 element. testString: assert($("h2").attr("style") === undefined); ```
## 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


```