How to add a class in h2 elements in HTML to change color?

How to add a class in h2 elements in HTML to change color?
0

#1
<style>
  h2 {
    .red-text{
      color:red;
    }
   }
</style>

<h2>CatPhotoApp</h2>

<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>

#2

You can’t nest selectors in CSS. It’s just

<style>
  .red-text {
    color: red;
  }
</style>

However, this alone won’t change the <h2>'s color to red. You’ll need to give it the class attribute with a value of red-text.

<h2 class="red-text">