Styling an element with an attribute set is easy: E[attr]
.
Is there any way to style an element with CSS2 based on the absence of an attribute, something like this E[!attr]
? (JavaScript solution is not an option).
For example, there are several class rules followed by id rule:
.abc {padding:1em;}
.def {padding:2em;}
#n a {padding:0;}
The html code is:
<div id="n"><a href="" class="abc">.</a><a href="" class="def">.</a></div>
Classes abc
and def
have lowerer priority against id-ed rule so both a
have padding 0. I can't change the sequence of rules above, but I can change id-ed rule add my own rules. I want to avoid writing rules like #n a.abc
for every class (there're many). Instead I need something like #n a[!class]
to keep all class-ed a
s intact.