- Click the Check button on the Web page.
You then see a report on the errors and the overall compliance of your
CSS code. As an example, I got these results from the validator:
W3C CSS Validator Results for file://localhost/C:\MyFirst.css
To work as intended, your CSS style sheet needs a correct
document parse tree. This means you should use
valid HTML.
Errors
URI : file://localhost/C:\MyFirst.css
Line: 13 Context : h1 , h2
Parse Error - text-align: center;
Line: 14 Context : h1 , h2
Parse error - Unrecognized : }
Warnings
URI : file://localhost/C:\MyFirst.css
Line : 5 font-family: You are encouraged to offer a generic
family as a last alternative
Line : 11 font-family: You are encouraged to offer a generic
family as a last alternative
Valid CSS information
p {
color : blue;
text-align : center;
font-family : arial !important;
font-size : 18pt !important;
}
Whew!
Do you see why the validator claims to have found an error in the h1, h2
selector rule? The rule doescontain an error, but the validator can’t be spe-
cific about what the error is or even precisely where. Here’s the validator’s
error message:
Line: 13 Context : h1 , h2
Parse Error - text-align: center;
Line: 14 Context : h1 , h2
Parse error - Unrecognized : }
The validator appears to have a problem with text-align: center;, but
that code actually works just fine — it’s not an error at all. Likewise, the val-
idator says it doesn’t recognize the colon and brace, whatever that means.
306 Part IV: Advanced CSS Techniques