+ 1
How to change <p> in css
Hello guys , im new here and my question is - if i have 2-3 <p> how can i make different style (in css) one by one not to all <p> at the same time . Tnx pre
5 Réponses
+ 6
You can add an id or a class.
an ID :
in HTML it will be :
<p> </p>
<p id="ID1"> ... </p>
<p id="ID2"> ...</p>
In the CSS you'll use the following to change the style of the second and the 3rd paragraphs with a different style for each one of them :
#ID1{
color:red;
}
#ID2 {
color:blue;
}
The first paragraph won't change, the second will have a red color and the 3rd will be blue.
An ID is unique, so you can use it when you want to have a unique style for that element.
If for example you want to change the second and the 3rd paragraphs both to red, you can use a class this way :
in HTML it will be :
<p> </p>
<p class="red"> ... </p>
<p id="red"> ...</p>
in the CSS you'll use the following to change the style of the second and the 3rd paragraphs both to red :
.red{
color:red;
}
You can also use nth-child () selector.
+ 4
hi
you can set class or id to p tag :
<p class="firstpclass"></p>
+ 1
Thanks you so much
0
what should i write in css
firstpclass {}
?
0
how can add html language in challenge