If we want to style some paragraphs or headlines by our choice in html,so how can we use class attribute to apply | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

If we want to style some paragraphs or headlines by our choice in html,so how can we use class attribute to apply

21st Aug 2020, 5:43 AM
Seyal Kandahari
Seyal Kandahari - avatar
5 Answers
+ 4
Use global class attribute in html tag Html <p class="p">. </p> <h1 class="p"> </h1> Css .p{ Your style goes here }
21st Aug 2020, 5:52 AM
TOLUENE
TOLUENE - avatar
+ 4
You can put your css code inside <style> tag in both body and head. But preferred place is head. In my 1st example both p and h1 share same class name. Suppose you are going to change the color. So select both with class selector .p{ color:red }
21st Aug 2020, 5:59 AM
TOLUENE
TOLUENE - avatar
+ 4
Oh i got the point you are telling about inline style. It is possible with style attribute. <p style="color:red" > it is a paragraph </p> Style attribute can contain any css property. or <html> <head> <style> .p{ color:red } </style> </head> <body> <p> it is a paragraph </p> </body> </html>
21st Aug 2020, 6:04 AM
TOLUENE
TOLUENE - avatar
+ 2
Md Sayed 🇧🇩🇧🇩 1.Where can we use our style set at head or body? 2.Can u tell me that I will declare my style set after paragraph or headline?
21st Aug 2020, 5:56 AM
Seyal Kandahari
Seyal Kandahari - avatar
+ 1
Md Sayed 🇧🇩🇧🇩 I mean can u tell me the structure direct in html without css?
21st Aug 2020, 6:02 AM
Seyal Kandahari
Seyal Kandahari - avatar