Use a CSS Class to Style an Element?

Use a CSS Class to Style an Element?
0

#1

Tell us what’s happening:

Your code so far

<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>
I've been stuck on this challenge for an hour. Who can help me. My h2 element is still black and has refused to change to red??

#2

Your code works here. Have you tried this in a different browser?


#3

Yes. I’ve tried it with Google Chrome and Dolphin. Still the same. What browser do you use?


#4

Your code works both on Firefox and Chromium. Hmm, weird, the code you posted works as it is. Are you sure the code that you posted is the same as the code that you were trying to submit?

If nothing else works you should probably try submitting an issue on GitHub.


#5

It worked for me in Chrome, too.

Have to tried rebooting? I know it’s nuts, but sometimes it is something simple like that.


#6

After spending quite some time on this section without success, but not being able to find any errors, I turned to the forum, only to find some 37 other postings on this same topic. One suggested trying another browser, so I switched from Firefox to IE and had no trouble except that only the header turned red, not the text. However I got the FCC tick and praise for the correct answer and compared it to what I had written on Firefox, which was identical, but no cigar. So without changing anything on the Firefox submission I hit submit again and hey presto this time it signaled success, except that again, only the header was in red not the text, though I believe the whole point of this exercise was to change the text color. So it appears the lesson I have learnt today with this exercise is that even the teachers sometimes get it wrong.
Worryingly, most of the other 37 posts were dated 2016 and this is now 08/2017, but nothing seems to have been fixed. Or have I got this all wrong?


#7

This happened to me on a few of the lessons, but I found out what would cause it for me was that I would accidentally erase other code when editing, and although I replaced what was erased exactly as it was before it took it as wrong when submitting.

I had to reset the text through the “Reset Your Code” button then make the edit making sure I didn’t delete any other text other than what I needed. That fixed the problem for me, maybe something similar is happening to you also?