Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
EN – Language: English
Free tool, nothing to install

CSS Validator
The Line, The Property, The Fix

The validator reads a stylesheet in the same manner as a web browser will, and then reports back to you which part of your CSS code it plans to discard. Each report contains a line reference, the problem-causing property, and what the parser was expecting. Any stylesheets you upload to this site remain within your own browser.

  • FreePrice
  • 6Checks
  • NoneSign-up
  • NoneUploads

CSS Validator

Read a stylesheet and name every declaration the browser would drop, with the line it sits on

What the reader found

Nothing read yet.

Ready. Paste a stylesheet, or press one of the sample buttons.

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.

An automatic check, not a final verdict

This tool reads your code as text. It cannot run every script or test every browser, so review each finding before you delete or rewrite anything.

Add a link to this tool on your own site

Copy the code below and drop it into your page. It places a link to this free tool.

Guides for this tool

Articles with worked examples, tables and a short video that help you get more from this tool.

  • Rem or Px in CSS: What to UseRem or Px in CSS: What to Use

    Rem vs px in CSS: the real difference, accessibility, when to use each, and a conversion table.

    9 minutes of reading · video guide inside

The short version

What A CSS Validator Catches

The fact that browsers are lenient with their handling of CSS (and thus will drop any rules they cannot interpret, without telling you) is what makes using CSS difficult. When this occurs, the user sees a visual error on the website.

This tool will tell you what parts of your CSS code the web browser will ignore. Each comment contains a line reference, the property or selector that is causing an issue, and why the parser could no longer continue.

It processes each line of the stylesheet as they appear, keeping track of whether it has entered into a rule, a string, a comment, or an at-rule. Since the state of the parser determines the meaning of each character, a left curly brace within a comment will not create a new block.

This CSS validation checks for six types of errors. Two types will cause your page to fail to load, while the other four will result in a missing declaration but won’t prevent the page from loading.

All checks are run in the same tab, which means that the stylesheet used on sites with confidentiality clauses will be the same as those that are open to the public.

How A CSS Validator Reads A Stylesheet

The reader moves through the entire text. For every character in the text, the reader determines if that character is part of a selector, a declaration block, a value, a string, or a comment.

Diagram of four CSS declarations: two kept by the parser, one with a wrong value and one misspelled, each with a note
Three valid declarations, two dropped, and a note for each one.

From there, it determines if an opening brace begins a block; if a colon begins a value; and if a closing semicolon ends a declaration. The grammar itself is concise, and the CSS Syntax Module is where the working group documents it.

Since the walk has state, a stray brace in a comment does not affect anything. If someone reads by counting characters they will think it is the beginning of a block and then misplace all of the lines following it.

The way you recover from your errors is as important as the way you find them. If a browser encounters a declaration that it cannot understand (parse), then it will move on to the next semicolon and continue. So, if there is a single error in your file, only that declaration is lost and not the entire file.

So a rule that lost a declaration can sit on a live site for months. The page keeps working, one property short, and nothing in the console says so.

Why Silent Drops Are Worth Finding

The cheapest error in CSS to commit and the most difficult to find is a spelling error in a property name. If there is even one letter wrong, then the entire declaration will be lost.

Counts grid for a broken stylesheet: 20 lines, 3 rules, 10 declarations, 3 selectors and 7 notes raised
Five counts, and the one that matters is the last: notes raised.

The element retains much of its original styling due to the remainder of the rule remaining in effect. So, the web page will appear nearly correct, with any discrepancies being attributed to other factors.

Units follow exactly the same rule. A length written without one is valid in a few places and invalid in most. Therefore the browser drops a margin of ten rather than ten pixels, and the space it was meant to create never appears.

A validator produces three lines from those three, and that is all there is to it. The browser will remain quiet, but your web page will produce a sound.

The Six Checks Explained One By One

The first check is brace balance. An opening brace with no match, or a closing one with no opener, gets a note naming the line where the count went wrong. This is the one mistake that can cost you the whole rest of the file.

CSS validator notes in line order, from a missing semicolon on line 2 to a stray closing brace on line 20
Six check families, each with a line number rather than a verdict alone.

The second is a missing semicolon. When you leave out a semicolon, the browser interprets the next declaration as part of the value for that declaration, so a single missing semicolon can result in the loss of two declarations. Both of these are listed in the note.

The reader will report any properties that are unknown to the reader. The reader will also report what is most likely a typing error and suggest the best possible replacement for the unknown property.

The fourth is a value which is unacceptable by the property. A value of "color" specified with a word (other than a valid color name) or a value of "length" specified as a percentage on a property that does not accept percentages.

The fifth one has an incorrect spelling. There are also units of measurement which do not exist in the list of accepted units and those units are used for properties where only a single numerical value can be entered.

The sixth check checks if you’ve duplicated a selector within the same block, or if you’ve used the same property more than once in the same rule. Since the last declared value takes precedence, a previous value can look official and be completely ineffective.

What Valid Is Not

The validator can answer just one question: "Will the browser be able to read (parse) this?" But, it cannot tell you if the rule you are using is a good one.

Two rows under the CSS validator result: what it checks, such as braces and units, and what it does not check
The first half is grammar and the second half is judgment. Only one of these parts is a validator job.

The point here is that a stylesheet may have passed all of your checks but it may still be incorrect. For example, a color that doesn’t meet contrast standards, a fixed width that breaks on small screens, or a font size specified as pixels when you should have used a relative measurement. All of these issues are not actually grammar errors.

Browser support works the same way. A property can be perfectly valid and still do nothing, because the browser has not implemented it. Validation says nothing about that, and a green result read as a compatibility promise will mislead.

This is why this page links to the Contrast Checker and Selector Tester. They will help answer the questions that a validator can’t.

Video guide

See the CSS Validator at Work, Start to Finish

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

Step by step

Checking A Stylesheet With The CSS Validator

It takes four steps, and not one of them asks you to sign up.

  • Paste the stylesheet

    So paste a whole file or one rule. Because the reader takes text rather than a compiled form, a fragment is fine as long as its braces balance.

  • Pick the strictness

    After you make your choice about how you would like to handle unknown properties (as either errors or warnings), because a new property can potentially be ahead of the current reader, the "Warning" level will allow the property to pass through as long as it has a notation attached.

  • Work through the notes from top to bottom

    In addition, you will be working down the panel. The notes are listed in line order, which means the top note often leads to the bottom two.

  • Fix, re-run, then copy

    Finally, edit the sheet in your own editor and paste it back to confirm the count is zero. After that, copy or download the clean file.

Why this page

Reasons To Check Your Stylesheet Here

Five reasons, and each one saves a debugging session.

  • It names the line

    As each note generated by the CSS validator includes a line number, it allows for direct access to that location within the document as opposed to having to read through the entire document. A two-hundred-line stylesheet will take about two minutes to complete.

  • It explains the reason

    A note in a CSS validator states what the parser expected, rather than simply stating that it halted. As a result of this, you will often find the correct solution within the note itself.

  • It reads the way a browser reads

    So a CSS validator handles strings, comments and at-rules in the exact same manner. So, a brace within a comment will not create an incorrect report.

  • Nothing uploads

    This is where you do all of your checking. So, a stylesheet with a privacy policy is exactly the same as one that is publicly available.

  • It stays quiet about taste

    Because grammar is the entire job, the tool makes no mention of what you named something, how many levels deep it was nested, or which units you chose. So, a green result means that the code has been parsed, and that is all.

Rules of thumb

Habits That Keep A Stylesheet Clean

Six habits that keep a stylesheet readable and easy to validate.

  • One declaration per line Thus, a missing semicolon will appear as a red line in your editor, not as a message here. And multi-line rules are much easier to view for differences.
  • Never write a length without a unit In order for a zero to be used by itself, no other units can be included. Since the browser removes the unit from a unitless length, the space that was supposed to appear does not exist, and it is difficult to work out why this happened.
  • Keep custom properties spelled once A custom property is a name you invent, so a typo in it is silent everywhere. Therefore declare it at the top of the file and copy the spelling rather than retyping it.
  • Validate before the minifier, not after A minifier trusts its input, so a broken rule comes out broken and harder to read. Since the line numbers survive in the unminified file, check that one first.
  • Watch the last rule in a block The last declaration can suffer from a missing semicolon with the least damage to the program, as well as hiding the mistake better than other declarations. Since the following line has a closing curly bracket, the syntax rules continue to apply, and the warning does not show up.
  • Treat a vendor prefix as normal A prefixed property is acceptable and the reader understands that. Thus, a warning for a prefixed property indicates that you should update the property instead of fixing a mistake.
Careful here

Six Ways Stylesheets Break Quietly

Each of these leaves the page almost right, which is what makes it slow to find.

  • A dropped declaration in a shorthand

    Watch out. When using a short form like margin expanded, it causes loss of the entire line and not just one part. This means all four sides will be moved, rather than just one.

  • A value that the property does not accept

    A percentage when the value needs a length, or a term when the value needs a numeric quantity. Since the browser continues to the next semicolon, the following declaration will remain intact.

  • A duplicate property in one rule

    The latter value will take precedence over the earlier one, and can appear to be valid. So, delete rather than comment out the original value, otherwise the next person reading the documentation may accept it as correct.

  • No semicolon right before a closing brace

    The last declaration in a block has the advantage that if you make an error there, it does not cost anything. Thus, it will pass through a review process, and it will only be noticed when someone else adds a declaration after it.

  • An unclosed comment

    If you leave a comment open, all rules following it will be ignored, meaning your entire page will render without styles from the point of the open comment, even though the file appears to be OK when viewed through a diff.

  • Trusting a green result on support

    A valid property may still not cause anything to happen in the browser that is of concern. Since validation is a matter of grammar, check the compatibility of the property against the specific target you are working on.

Questions

CSS Validator Questions

Does this CSS validator cost anything?

Yes. You never sign up, never hit a cap and never meet a paywall. So you validate as many stylesheets as you like.

What does a CSS validator look for?

Six different kinds of errors: unbalancing of braces, missing semicolons, unknown property names, values for which a property can’t accept, incorrectly written unit abbreviations, and duplicate properties within a single rule.

Does it check my CSS against the specification?

It will check against the grammar defined by the CSS syntax module and also against a list of current properties with the possible values they can have. This means that a new property could be flagged as incorrect until it has been added to the list.

Why does my CSS look fine if it has an error?

Because a browser skips to the next semicolon and carries on. So one bad declaration costs one declaration, and the page keeps rendering without it.

Does it change my stylesheet?

No, the reader will report back to you and the file will remain exactly as you submitted it. Any edits or changes must be made by yourself within your editor.

Is the stylesheet I paste sent to a server?

No, the entire check runs within the same browser tab, so any confidential stylesheets will remain on your device.

Will it validate SCSS or Less?

No. These tools give extra features to CSS (nesting, variables, etc.), so convert them using the preprocessor converter before validating the resulting standard CSS.

Will it check browser support?

No. A property may be validly written and yet produce no effect in the browser. Validation refers to the grammar of the code; but whether or not the property is supported is a different matter.

What is the closest thing to a real error?

Missing an unbalanced brace. A single missing brace means that the browser reads the rest of the file at the wrong level, and so all rules following that missing brace will be lost.

Will it flag a vendor prefixed property?

The reader understands what a "prefixed property" is and is OK with it. So, you can pass off a six prefix block for one single feature with no comment.

Can I validate a fragment rather than a whole file?

Yes. A single rule or a set of rules will function properly if all of its curly brackets are balanced. So, the number of lines referred to in the output is based upon what you have pasted into the buffer, not what was in a file.

Does it check custom properties?

It checks the syntax and the use. Because a name you invented has no spelling to verify, it cannot tell that two spellings were meant to be one.

How does an error differ from a warning?

An error means the browser will drop the declaration. A warning means this reader does not know the property, which may simply mean it is new.

Can it count my rules and selectors?

Yes. The report gives you the count of rules, declarations, and selectors; this can help you reduce the size of your file.

Does it format or minify the stylesheet?

We chose not to, and for good reason. Decisions about how to format and validate data are separate. The minifier used in this process handles the whitespace.

Why is a valid rule of mine still not applying?

The primary reason for failure to match is generally due to the selector as opposed to the declaration itself. So, you should use the selector testing tool, which will ask if your selector matches any of the elements on the page.

Does it run on phones too, or only on desktops?

Yes. The panes stack and the notes wrap. So a quick check is possible away from a desk, though a long file is easier on a keyboard.

Can I download the validator notes?

Yes. The report can be downloaded as a text file that can be used for a ticket or review comment.

Is the stylesheet still mine?

No, you can upload any number of files. There is no copyright claim on any of those files, and no acknowledgment will be made for them.

Is an account or a browser add-on needed?

No. There is no sign-up, no plugin and no extension to add. So you close the tab when the sheet is clean.

Keep going

Handy Companion Tools For This Job

Four pages the same job usually leads to.

  • CSS minifier

    Once the page is clear of all comments and line breaks (whitespace), remove the whitespace. As a web browser will download every comment and every newline, use minification after validation has occurred, and not before.

  • CSS selector tester

    In addition, verify if the selector has any matches. A rule that doesn’t have matches will fail silently, so this is another aspect of the same process.

  • Color code picker

    A correct color choice can still fail to meet the required contrast ratio, so make sure to check the ratio before selecting your palette.

  • CSS preprocessor converter

    In order for the validator to be able to read your code if it’s written in SCSS or Less, you’ll need to convert it to plain CSS.

Find The Declaration The Browser Dropped

Paste the stylesheet and then read the comments in the order they were written. Fix the first comment you see and then re-run. No files will be uploaded and there will be no changes made to your computer. Most stylesheets are free of errors by the time you finish drinking your cup of tea.

Prefer Denwix on GoogleReview Denwix on Google