CSS Validator
Paste your CSS into the editor and click Validate Code to instantly check your code for errors, warnings, and best practice issues. Results are returned with exact line numbers so you can jump straight to the problem.
Unlike older tools, this validator is built for modern CSS. Custom properties,
@supports, @layer, @container,
color-scheme, oklch(), viewport units like
dvh and dvw, and many other contemporary features are
all recognised and validated correctly - without generating false positives on
code that is perfectly valid.
- Errors, warnings, and informational notices clearly separated by severity
- Accurate line numbers for every issue reported
- Shorthand property validation including
transition,animation,border, andbackground - CSS variable declaration and usage tracking
calc()expression syntax checking- Selector validation including combinators, class and ID naming rules
@media,@supports,@keyframes, and@containersupport- Summary statistics for every stylesheet validated
CSS Validator
Results
Stats
Note: This validator will only validate CSS, to validate HTML code please use this html validator.
About CSS Validator
A CSS validator is an online service that checks the validity of CSS code. CSS is a stylesheet language used for describing the presentation and formatting of web documents, including HTML and XML. CSS validators help web developers and designers ensure that their CSS code adheres to the CSS specifications and does not contain syntax errors or other issues that could affect the rendering of web pages in different web browsers.
Here are some common tasks performed by CSS validators:
Syntax Checking: CSS validators check for syntax errors in your CSS code. They ensure that you have used the correct syntax for CSS properties, values, and selectors.
Compliance with Standards: They verify that your CSS code complies with the CSS specifications set by the World Wide Web Consortium (W3C). This helps ensure cross-browser compatibility.
Detecting Deprecated or Nonstandard Code: CSS validators can identify and flag deprecated or nonstandard CSS properties, which may not be supported in modern browsers or may lead to compatibility issues.
Debugging and Troubleshooting: CSS validators can help you find and fix issues in your CSS code, making it easier to maintain and update your stylesheets.
Web developers often use these validators during the development and testing phases of a website to ensure that their CSS code is error-free and follows best practices. By doing so, they can create websites that look consistent and perform well across different browsers and devices.
Issue Severity Levels
Every issue reported by the validator is assigned one of three severity levels, so you can prioritise what needs fixing.
Errors are genuine problems that will prevent your CSS from
working as intended. This includes unknown properties, invalid values, missing
or mismatched braces and semicolons, invalid selectors, malformed
calc() expressions, and @media or
@supports conditions with incorrect syntax.
Warnings are issues that will not necessarily break your CSS today but are likely to cause problems or indicate code that should be revisited. Obsolete vendor prefixes, deprecated properties, missing unprefixed counterparts, empty rule blocks, and undeclared CSS variable usage all fall into this category.
Info notices are purely advisory. The CSS is valid and will
work correctly, but the notice highlights something worth knowing about - such
as an unnecessary unit on a zero value, use of !important,
duplicate selectors, @import performance implications, or
unquoted font family names.
Property Validation
The validator maintains a comprehensive list of known CSS properties covering
the box model, layout, typography, colour, visual effects, animation, grid,
flexbox, and more. Unknown properties are flagged as errors. Vendor-prefixed
properties (-webkit-, -moz-, -ms-) are
allowed through without error, though obsolete prefixes that are no longer needed
are flagged as warnings, and prefixed properties missing their unprefixed
counterpart are flagged as errors.
Value validation is performed per property. Keyword properties such as
display, position, and overflow are
checked against their allowed keyword lists. Length values are checked for valid
units. Colour values are validated across hex, named colours, rgb(),
hsl(), oklch(), and other modern colour functions.
Numeric properties like opacity and font-weight are
checked against their valid ranges.
Shorthand Validation
Shorthand properties present a particular challenge for validators because their
values can combine multiple types in any order. This validator takes a pragmatic
approach: shorthand values are tokenized carefully, respecting CSS functions like
linear-gradient() and rgb() as single units, then each
token is checked against colour validators, length validators, keyword lists, and
- for transition and animation - time unit requirements.
Animation names are treated as valid identifiers, so animation: fade 1s ease
will not generate false positives even if fade is defined in a
separate file.
Selector Validation
Selectors are parsed and checked for a range of common mistakes. Invalid
combinator characters like < are caught. Consecutive combinators,
selectors ending or starting with a combinator, and invalid .# or
#. combinations are all flagged. Class and ID names beginning with
a number are reported as errors. Escaped characters in selectors are correctly
recognised and allowed through without false positives.
At-Rule Validation
At-rules are validated both structurally and semantically. @media
conditions are checked to ensure feature queries like max-width: 600px
are wrapped in parentheses, while plain media types like print and
screen are correctly allowed without them. @supports
and @container conditions are checked for the presence of
parentheses. @keyframes blocks are validated for a name, and keyframe
selectors are checked to ensure they use from, to,
or valid percentage values. Unknown at-rules are flagged as errors.
Structural Validation
The validator catches structural problems that other tools often miss or handle poorly. Missing opening or closing braces are detected and reported with the appropriate line number, and parsing continues past the error where possible so that a single structural mistake does not suppress all subsequent errors. Missing semicolons are detected including the common case where a missing semicolon causes the next property name to be parsed as part of the preceding value - generating a targeted, readable error message rather than a confusing one about an invalid value.
Summary Statistics
Every validation run produces a statistics summary alongside the error list. The summary includes the total number of rules and declarations in the stylesheet, the number of unique properties used, the five most frequently used properties, CSS variables declared and referenced, at-rules present, and a breakdown of errors, warnings, and info notices. This gives a useful at-a-glance overview of the stylesheet's complexity and health.
Frequently Asked Questions
What is a CSS validator?
A CSS validator is a tool that analyses your CSS code and reports errors, warnings, and informational notices. It checks for unknown properties, invalid values, structural problems like missing semicolons or braces, and code quality issues like duplicate selectors or the use of deprecated properties.
How is this validator different from W3C or CSSLint?
Unlike the W3C validator or CSSLint, this tool is actively maintained and
supports modern CSS including custom properties, @supports,
@layer, @container, color-scheme,
oklch(), dvh/dvw units, and many
other contemporary features. CSSLint in particular has not been updated in
several years and flags perfectly valid modern CSS as errors.
What types of issues does the validator report?
Issues are classified into three levels. Errors are genuine problems that will prevent your CSS from working correctly. Warnings are code quality issues that may cause problems or indicate code worth revisiting. Info notices highlight best practice suggestions where the CSS is valid but could be improved.
Does the validator support CSS custom properties (variables)?
Yes. Custom properties declared with the -- prefix are fully
supported. The validator tracks all variable declarations and usages within
your stylesheet and will warn if a variable is used but not declared in the
same file - correctly noting it may be defined elsewhere, such as in a
separate stylesheet or :root block.
Why is a valid property being flagged as unknown?
The validator maintains a curated list of known CSS properties. If a newer
or less common property is not yet included, it may be flagged. Vendor-prefixed
properties such as -webkit- and -moz- are allowed
through without error, and CSS custom properties starting with --
are always valid.
What does the validator check inside shorthand properties?
Shorthand properties like border, background,
font, transition, and animation are
partially validated. Colour values are checked for validity, length values
are checked for recognised units, time values in transition and
animation must include a unit (s or ms),
and tokens are checked against recognised keywords. Full deep parsing of
all shorthand combinations is intentionally avoided to prevent false positives.
Why does the validator warn about duplicate selectors?
Duplicate selectors within the same stylesheet often indicate copy-paste
errors or unintentional redundancy. The validator only flags duplicates at
the top level - selectors repeated inside @media or other
at-rules are not flagged, as overriding styles for different breakpoints
is standard and expected practice.
Are @media, @supports, and @keyframes supported?
Yes, all major at-rules are supported. @media conditions are
validated to ensure feature queries are wrapped in parentheses while plain
media types like print are correctly allowed without them.
@supports conditions are checked for correct syntax.
@keyframes names are tracked and cross-referenced with
animation properties. @layer and
@container are also recognised and validated.
What does the summary statistics panel show?
The statistics panel gives an overview of your stylesheet including the total number of rules and declarations, unique properties used, the five most frequently used properties, CSS variables declared and used, at-rules present, and a full breakdown of errors, warnings, and info notices found.
Is my CSS sent to a server?
Your CSS is sent to the server running this tool via a standard HTTP POST request. It is processed entirely server-side and is not stored, logged, or shared with any third party.
Why does the validator flag !important?
!important is flagged as an informational notice rather than
an error or warning. It is entirely valid CSS but is widely considered a
code smell because it overrides the natural cascade and can make stylesheets
difficult to debug and maintain. The notice is purely advisory.
Does the validator support calc()?
Yes. calc() expressions are validated to ensure they contain
at least one operator, that + and - operators are
surrounded by whitespace as required by the CSS specification, and that
there is no division by zero. Nested calc() expressions and
calc() used within shorthand values are both handled correctly.
