Is it possible to select all elements that do not have a CSS class?


The W3C Recommendations defines the ability to select any anchor which has a defined class by using A[CLASS]{/*Code*/}, but is there an antecedent?

Can I select all anchors that do NOT have a class?

My instinct is to use A[~CLASS]{/*Code*/}, but that isn't documented, and A[CLASS=]{/*Code*/} selects all anchors which have a class name which is an empty string (for instance, <A CLASS="" HREF="">This anchor has a class, but it's empty.</A>).

Example usage

In this code, I only want classless links to be green.

<LINK REL="stylesheet" TYPE="text/css" HREF="" />
color:#FF0000 !important;


<A HREF="http://fakesite.not/" CLASS="deadLink">This link is red, as specified by the CSS above.</A>
<A HREF="">This link is green, as specified by the CSS above.</A>
<A HREF="#/childpage/" CLASS="childLink">This is a link to a child page, and is styled by external uneditable CSS. That CSS doesn't specify a color, so it is green, even though that might not be the intended effect.</A>

Use something like this:

a:not([class]) {
    /*some styling here*/

Little demo: little link.