DaBlick DaBlick - 26 days ago 9
CSS Question

CSS pattern that matches when style is NOT present

I have a library (PrimeFaces) that adds a style to a

<th>
when a column is sortable. But I want to apply my own style when a column is NOT sortable: i.e. when that style is NOT in the
<th>


Is there a way to do a CSS selector for when a style is NOT present without making any other presumptions about what is/isn't in the list of the element's style classes?

That is, I need to do this strictly within CSS without modifying the HTML.

Answer

You can use :not() selector:

table th:not(.sortable){  }
Comments