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
card { /* missing . for class */
padding: 20px;
}
div:hoover { /* misspelled pseudo-class */
color: red;
}
input[type=text { /* unclosed attribute selector */
border: 1px solid;
}.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 ValidatorHostinger — Fast & Affordable Web Hosting
Deploy clean, validated CSS on reliable hosting.
Related CSS Errors
Unclosed CSS Bracket
How unclosed curly braces break your entire stylesheet. Find and fix missing closing brackets.
Empty CSS Rule
Why empty CSS rules bloat your stylesheet. How to find and remove unused selectors.
Unknown CSS Property
How to fix unknown or misspelled CSS property names. Common typos and non-standard properties.