Home › Developer Tools › CSS Validator

CSS Validator

Paste a stylesheet to find syntax errors, unknown properties, invalid values, broken selectors and media queries, each with its line and column. Then let the validator fix the structural mistakes and reformat the CSS for you.

Last updated:

    Tip: press Ctrl + Enter to validate and click an issue to jump to its line. Your stylesheet is checked locally and never uploaded.

    Advertisement
    Advertisement

    How to use the CSS Validator

    1. Paste your CSS into the input, open a .css file, or load the sample with errors.
    2. Read the issues list: errors (red) break or invalidate CSS, warnings (amber) point to likely mistakes. With Validate as I type on, the list updates while you edit.
    3. Click an issue to jump to the exact line and column in the editor.
    4. Press Fix & format to get a corrected, consistently indented copy: missing semicolons and closing braces are added and stray braces removed.
    5. Copy or download the fixed CSS, and fix remaining value or property errors by hand.

    What happens to invalid CSS in the browser

    CSS is designed to fail softly: browsers skip what they don't understand and keep going. That makes mistakes easy to miss, because the page still renders, just not as intended. The error-handling rules from the CSS Syntax specification explain what each problem costs you:

    ProblemWhat the browser drops
    Unknown property or invalid valueOnly that declaration; earlier declarations of the same property still apply.
    Missing semicolonThe declaration and the next one, which become a single invalid value.
    Invalid selector in a list (a, b:hoverr)The entire rule, including the valid selectors.
    Missing closing braceFollowing rules are read as nested inside the open block, which usually breaks them.
    Unclosed stringThe rest of the line becomes a bad string; the declaration is dropped.
    @import after other rulesThe whole @import.
    Invalid media queryTreated as not all: the block never applies.

    Fixing the most common CSS errors

    • Unknown property: usually a typo (colr, backround, font-wieght); the validator suggests the closest real property. Some properties need a vendor prefix in older browsers.
    • Invalid value: check units (16pxx, a number without a unit such as width: 10), hex colors (3, 4, 6 or 8 hex digits) and the order of shorthand parts. The "Expected" line shows the formal syntax.
    • Missing semicolon: every declaration except the last one in a block must end with ;. Adding it to the last one too is good practice.
    • Invalid pseudo-class: :hoverr, ::befor or a single colon where two are required for newer pseudo-elements such as ::placeholder.
    • Media query syntax: write and (max-width: 600px) with a space after and and a colon inside the parentheses.

    Once the stylesheet is valid, compress it for production with the CSS Minifier, or check selector weights with the CSS Specificity Calculator.

    Frequently asked questions

    How is this different from the W3C CSS Validator?

    Both report syntax errors and invalid properties or values. This validator runs entirely in your browser (nothing is uploaded), updates as you type, highlights lines in the editor, suggests the property you probably meant, understands modern CSS such as nesting, container queries and :has(), and can fix structural mistakes automatically.

    How are property values validated?

    Each value is checked twice: against the CSS specification syntax database used by the css-tree library (based on MDN data), and with your browser's own CSS.supports() engine. A value is accepted when either says it is valid, so new features your browser supports are not flagged.

    Why are values with var() not checked?

    A value that uses var(), env() or attr() is only known when the page is rendered, so neither a validator nor the browser can check it in advance. The property name is still checked.

    What does the auto-fix change?

    It adds missing semicolons between declarations, closes unclosed blocks, strings, comments and brackets, removes stray closing braces and then reformats the stylesheet with consistent indentation. It does not guess replacements for unknown properties or invalid values; those stay listed as errors for you to decide.

    Why is a valid selector reported as an error?

    Selectors are checked with your browser's selector engine. A vendor-specific pseudo-element of another browser (for example ::-moz-selection in Chrome) is reported as a warning. If one selector in a comma-separated list is invalid, browsers drop the whole rule, which is why this matters.

    Does it support SCSS, Less or Tailwind directives?

    No, it validates plain CSS as browsers read it. Preprocessor syntax such as $variables, @mixin or @tailwind is reported, because it has to be compiled to CSS first.

    What counts as an error and what as a warning?

    Errors make browsers ignore part of your CSS: invalid syntax, unknown properties, invalid values, invalid selectors and misplaced @import. Warnings are valid CSS that is probably a mistake or has no effect: duplicate declarations, empty rules, unknown vendor-prefixed properties, old hacks and media types that never match.

    Are all the tools on FreeToolCabin tested for quality and accuracy?

    Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

    Related tools

    CSS FormatterBeautify CSS with indent controls and optional property sorting.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.HTML FormatterBeautify and indent HTML code with a live preview.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.XML FormatterBeautify, validate and minify XML with a collapsible tree view.ZIP File CreatorCompress files and folders into a ZIP.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.JSON MinifierMinify and validate JSON, sort keys and see exactly how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.HTML ValidatorCheck HTML for errors and warnings with line numbers, locally or with the W3C Nu checker.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.JavaScript ObfuscatorObfuscate JavaScript with string encoding, renaming and control-flow flattening presets.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.XSD ValidatorValidate XML against an XSD schema in your browser and see each error with its line number.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.Luhn Algorithm CheckerValidate numbers with the Luhn mod 10 check or calculate the missing check digit, step by step.
    See all 41 Code Formatters & Validators →