Close Circle Icon
This forum is now read-only. Please use our new forums at discuss.codecademy.com.
0 points
Submitted by Alessandro Valente
6 years ago

What if I want two or three or four different Paragraphs to be all seperate colors?

Does CSS only apply to ALL of a certain SELECTOR? or can I pick and choose different colors, fonts, sizes but for the same type of selector? Example:

< p >This is a sentence.< /p >”

< p >This is another sentence.< /p >

So, can I choose, lets say, two different colors for the two different sentences in CSS? or because there is more than one, I now have to edit their styles individually in HTML?

Answer 53ed1141282ae3b406000137

0 votes

Permalink

You can using IDs or classes. To target specific sections like

‘s. Hope this helps.

Here is the html and css for an example of using divs and classes. HTML:

<!doctype html>
<html>
    <head>
    <link rel="stylesheet" type="text/css" href="test.css">
    </head>

    <body>
    <p id="one"><p>Sample Text one</p>
    <p id="two"><p>Sample Text two</p>
    <p class="three">Sample Text three</p>
    <p class="four">Sample Text four</p>
    </body>
</html>

CSS:

#one{
    font-family: 'Impact';
    color: red;
    font-size: 25px;
}
#two{
    font-family: 'Times New Roman';
    color: blue;
    font-size: 50px;
}
.three{
    font-family: 'Impact';
    color: red;
    font-size: 25px;
}
.four{
    font-family: 'Times New Roman';
    color: blue;
    font-size: 50px;
}

344 points
Submitted by atroy2
6 years ago

1 comments

pamperedideas 6 years ago

perfect soln!!!!

Answer 53ed6c367c82caa2df0006a1

0 votes

Permalink

Ah thank you! That makes so much sense now! I am about to learn IDs and Classes so I think I got too far ahead of myself xD

Thanks again!

139 points
Submitted by Alessandro Valente
6 years ago