Skip to content

selector-no-invalid

Disallow invalid selectors.

a ) b {}
/* ↑
* Selectors like this */

Use this rule to avoid rules that browsers ignore. One invalid selector invalidates the whole selector list.

This rule considers selectors defined within the CSS specifications, up to and including Editor’s Drafts, to be valid.

This rule supports 2 message arguments: the selector and the reason it is invalid.

{
"selector-no-invalid": true
}

The following patterns are considered problems:

a ) b {}
:nth-child(2n+) {}
[0foo] {}
:dir(foo) {}
:not(::before) {}
::slotted(a .foo) {}
a::after .foo {}
::after::before {}

The following patterns are not considered problems:

a b {}
:nth-child(2n+1) {}
[foo] {}
:dir(ltr) {}
:host(.foo) {}
::before::marker {}