Skip to main 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.

warning

This rule is only appropriate for CSS. You should not turn it on for CSS-like languages, such as SCSS or Less.

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

Options​

true​

{
"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 {}