freeCodeCamp Challenge Guide: Use a CSS Class to Style an Element

the problem is between the style class.
here’s the code.

h2.red-text { color:red; }

don’t put a space between h2 and the dot.

1 Like

I had a code and it was:

h2.red-text{ color: red }

CatPhotoApp

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

hay I hope this helps a little im stack on the four question

h2 { color: red; }

CatPhotoApp

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

How am I supposed to make my stylesheet declare a red text. I am very confused.

“Your stylesheet should declare a red-text class and have its color set to red.” What does this mean??

figured it out it looks like this
.red-text {
color: red;
}

Hey guys i figured it out, i was stuck at it for like 2days.
h2.red-text{color:red;}
.red-text{color:red;}

1 Like

I had the correct solution for quite awhile, but was unable to get it to accept my code. finally I tried a different browser and it worked fine.

If you have the correct code but it is not accepting it. Try a different browser. In my case Edge failed but Chrome worked.

This forum is fantastic :slight_smile:

I struggled to determine exactly what the CSS was in relation to the HTML, think I’ve got it now tho.
Cheers

Thank you so much UntrueHunter.

CatPhotoApp

” is not working for me. h2 is still in black

I don’t know but there is a dot if u can see behind the red-text.
Hope that I helped.

@janika that’s what I have in line 3, but my problem is line 6

CatPhotoApp

it's not working

@gamingchampion22 - you’re referring to the color line, i’m asking about the class line

h2.red-text{color: red;}

CatPhotoApp

this will do

My code runs fine on desktop but mobile is really choppy to work with and even when I get it done the class-selector just won’t work to color the element. I went through letter by letter to make sure it was the same as the way I had gotten it to work on desktop, but the CSS just wouldn’t run.

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

<h2 class="red-text">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>
4 Likes