html - Stop overriding from previous CSS properties -


for example, given these 2 rules

p { color: red; background: yellow } p { color: green } 

paragraphs appear in green text. have yellow background however, because first rule not negated. value color property overridden second rule background-color not in conflict, still applies.

so there anyway stop applying background color property?

i requiring such method because first rule may have n no. of attributes don't know beforehand. looking forward positive reply.

that's why can define classes in css.

the style defined same element overwritten if there duplicated properties , inherited previous definition same element.

try:

css

p.red { color: red; background: yellow } p.green { color: green } 

html

<p class="green">some text</p> <p class="red">another text</p> 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -