Ivan Topić Ivan Topić - 23 days ago 6
CSS Question

Target element with target which isn't a specific class

How can I target a link with _BLANK target but which doesn't have specific class?

a[target="_BLANK"] {
// Do something if this link isn't .skip-this class
}

Answer

Simply use the CSS :not selector

CSS

a[target="_BLANK"]:not(.skip-this) {
   color: red;
}

a[target="_BLANK"]:not(.skip-this) {
   color: red;
}
<a href="" target="_BLANK" class="skip-this">Hello</a>
<a href="" target="_BLANK">Hello</a>