Selector-paragraphs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Selector-paragraphs

P{color="red";} applies to all paragraphs..what if you want to style just one paragraph out of a given number of paragraphs

14th Jan 2020, 8:38 PM
Beautiful Mind
Beautiful Mind - avatar
4 Answers
+ 3
If you want to style just one paragraph out of a given number of paragraphs, you need to apply the id or class attribute to that paragraph. For example: HTML: <p id="first_paragraph">Hello</p><!--id is a unique attribute, and only one tag should use it--> <p class="blue_paragraph">World!</p><!--classes, on the other hand, can be used for multiple tags--> CSS: #first_paragraph { color: orange; } .blue_paragraph { color: blue; } Try it out, this should be in the CSS course here.
14th Jan 2020, 8:54 PM
Jianmin Chen
Jianmin Chen - avatar
+ 3
Have an ID set for that one paragraph, and define the specification in CSS. * HTML <p id="diff">this is one of a kind</p> <!-- color will be red --> <p>just a regular paragraph</p> <!-- color will be default --> * CSS p#diff { color: red; }
14th Jan 2020, 8:59 PM
Ipang
+ 2
Thank you
14th Jan 2020, 9:03 PM
Beautiful Mind
Beautiful Mind - avatar
+ 1
Yes thanks a lot...and I've also seen what you said in the lessons
14th Jan 2020, 8:58 PM
Beautiful Mind
Beautiful Mind - avatar