0

Is not it enough to use only . foo class to style div? Why mdn use style attribute with . foo class?

.foo[style*="color: red"] { color: firebrick !important; } <div class="foo" style="color: red;"> What color am I? </div> Ref::https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

12th Feb 2021, 4:17 PM
NUR ISLAM
NUR ISLAM - avatar
3 Answers
+ 1
NUR ISLAM but it changes color for every .foo class , right ? As i said the above only selects elements with inline style "color:red" and then overrides it to add firebrick color. Consider other class foo elements having different color other than red and we don't want to change their colors . But this is just what i see , if you wanna argue and know about the intention behind it , maybe send them an email (if it is possible!) and if you need an example of what i mean, i will code it for you!
13th Feb 2021, 12:04 AM
Abhay
Abhay - avatar
+ 1
Maybe to make it more clear to user that they are overriding only .foo class elements having inline style with attribute color set to red.
12th Feb 2021, 4:29 PM
Abhay
Abhay - avatar
0
Abhay but . foo{ color:firebrick ! important; } Does the same thing. So why I need to use style attribute?
12th Feb 2021, 11:16 PM
NUR ISLAM
NUR ISLAM - avatar