I have css option for all divs
div {
background: blue;
}
How can I make div with id myDiv that will not inherit any css option except #myDiv.
I have css option for all divs
div {
background: blue;
}
How can I make div with id myDiv that will not inherit any css option except #myDiv.
Copyright © 2021 Jogjafile Inc.
You cannot, that's why they are called Cascading Style Sheets.
The most common solution in such cases would be to override the
backgroundattribute on#myDivwith another rule.In this specific case, you have the option of using the CSS3
:notpseudo-class as indiv:not(#myDiv) { background: blue }, but then you have to account for browser compatibility (summary: works on everything except for IE < 9) so I don't think this is a practical option just yet.