</>
ValidateHTML

Invalid CSS Selector

An invalid selector causes the entire rule block to be ignored, even if the declarations inside are perfectly valid. Common mistakes include forgetting the dot for class selectors, using invalid pseudo-classes, or malformed attribute selectors.

Why It Matters

Unlike invalid values (where only one declaration is skipped), an invalid selector discards ALL declarations in the rule. This makes it one of the most destructive CSS errors per character of mistake.

Code Examples

Bad CSS
card {                         /* missing . for class */
  padding: 20px;
}

div:hoover {                   /* misspelled pseudo-class */
  color: red;
}

input[type=text {               /* unclosed attribute selector */
  border: 1px solid;
}
Good CSS
.card {
  padding: 20px;
}

div:hover {
  color: red;
}

input[type="text"] {
  border: 1px solid;
}

How to Fix

  • 1Class selectors start with a dot (.card), ID selectors with a hash (#header).
  • 2Check pseudo-class spelling: :hover not :hoover, :focus not :focuse, ::before not :before (use double colon).
  • 3Attribute selectors must be closed: [type="text"] not [type="text".
  • 4Use quotes around attribute values: [type="text"] not [type=text] (quotes are safer).

Check Your CSS Now

Our CSS validator detects this error automatically and shows the exact line number.

Open CSS Validator
Recommended

Hostinger Fast & Affordable Web Hosting

Deploy clean, validated CSS on reliable hosting.

Get 80% Off Hosting →

Related CSS Errors

View all CSS errors