Reputation: 7243
Is there a CSS way to select an element that looks like that by class?
<a class="" href="...">
Like a selector for empty class declarations?
Upvotes: 25
Views: 19050
Reputation: 50269
Provided the class
attribute is present as you say you can use the attribute selector like this:
<a class="" href="...">asd</a>
a[class=""] {
color: red;
}
If you want this to work when there is no class
attribute present on the element you can use :not([class])
.
<a href="...">asd</a>
a:not([class]) {
color: red;
}
These can then be combined together to handle both cases.
<a href="...">asd</a>
<a class="" href="...">asd</a>
a[class=""],
a:not([class]) {
color: red;
}
Upvotes: 35