0

Is there any chance, a div call a particular css and its class. when i include two css on my html header both are have some same class.In case i have css1
.h1 text-align:center;color:red;
and css2
.h1 text-align:left;color:blue;.Now i need to call cssl from a div with h1 class in css1.

3
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by rotten69
0

I suspect the best approach is if you are unable to have unique classes and ids, then if you need to ensure that a specific style is applied, use the "!important" rule to ensure that the styles you need to ensure are applied, do get applied. Styles are normally applied in order as they are read by the browser. So for example,

.h1 {text-align:center;color:red !important;}
.h1 {text-align:center;color:blue;}

In this example, the color red will be applied regardless of the order the styles come into the browser.

0

@JorgeM.. so what happens to the blue colour in this case? I never used the !important rule.

0

I don't get why someone would even bother defining a second colour... Is that in the case where if a colour that has !important rule defined on, fails then the second colour will be applied automatically?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.