Use a CSS Class to Style an Element / your stylesheet should declare a red-text class and have its color set to red

Use a CSS Class to Style an Element / your stylesheet should declare a red-text class and have its color set to red
0

#1

Tell us what’s happening:
I am completing the first couple of exercises with which I can’t seem to pass the “Your stylesheet should declare a red-text class and have its color set to red.” I can’t seem to make out how to write the code in correctly to fulfill the function it is asking to do. I am confused weather i should just write “red-text” by its self in the stylesheet or should I write it with “h2 {class=“red-text”}”?

I know its probably simple but I’ve been having trouble. Can someone help me.

Greatly appreciate it!

Chris

Your code so far

<style>
  h2 {class="red-text"}
</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>

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.3 Safari/537.86.7.

Link to the challenge:


#2

Look carefully at the explanation and example for declaring a class in the stylesheet. The syntax is very different from what you have here.


#3

CSS can target parts of your html in 3 main ways:

class
ID
element

so if you had the following:
<p class ="red-text" id="myid"> example text</p>

the class is red-text, the id is myid, and the element is p.

you can target each of these in css using the following:

class uses a # before the class name you are trying to style
id uses a . before the class name you are trying to style
and element doesn’t use anything before the class name you are trying to style

so with this example:
<p class ="red-text" id="myid"> example text</p>

to edit all elements with a specific class you would use:
#red-text {
color: red;
}
(this will make all elements with class = “red-text” red.

to edit the id you would use:
.myid {
color: red
}
(id’s are supposed to be unique in your html, so this will just change one element.)

to edit all paragraph elements:
p{
color: red;
}
(this will change all paragraph elements to red)


#4

How can i improve my few i already learnt?