Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling different paragraphs with different styles using CSS and HTML

I have a question on using the class tag on paragraph tags. I want the external Css file to style a paragraph a certain way while leaving all the other paragraphs to the default style.I did some googling and reading and found if i add <p class="somename" > then in the css file i can change that paragraph using p.somename{ color: blue;} But what i found is p{color: red;} seems to be affecting them all.

This was just a example problem. The main problem im facing is that i dont want p.somename to have a background border.And the default <p> has borders.

like image 272
MikanPotatos Avatar asked May 20 '26 15:05

MikanPotatos


2 Answers

In HTML,

<p id="colorblue">some lorem ipsum here</p>

In CSS,

 p #colorblue{
color: blue
}

Or tepkenvannkorn's answer will work.

p.somename { color: blue !important; }
like image 167
Sarathlal N Avatar answered May 22 '26 07:05

Sarathlal N


Put p.somename{ color: blue } to the bottom comparing to p{ color: red} or you can use !important to foce your style to overwrite. for example,

p.somename {
   color: blue !important;
}
like image 31
Tepken Vannkorn Avatar answered May 22 '26 09:05

Tepken Vannkorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!