untitled

(John Hannent) #1
Valid CSS information

p {
color : green;
text-align : center;
font-family : arial !important;
font-size : 18pt !important;
}

h1 , h2 {
font-family : ravie !important;
font-style : normal !important;
text-align : center;
}

This time through the validator, the H1, H2 section has been moved down from
the error zone into the valid zone (meaning the code now passes their tests).

When the validator issues a warning, that’s less severe than an error. A warn-
ing just means that your code might not work universally on all past and
future devices, including browsers from 1995 or Internet screens built into
refrigerator doors. A warning means, well, your code does work in Internet
Explorer, but you really should give a default font family, just in case Arial
ever gets replaced by something else and you want to ensure that the font
remains sans serif. Big freakin’ deal.

Did that comment about a “correct document” send chills down your spine?
The validator always displays the comment To work as intended, your
CSS style sheet needs a correct document parse tree. This
means you should use valid HTML. Actually, you can just ignore it. It’s
always there as a scold to hector you. Your HTML may well not have anything
wrong with it — they’re just telling you to check it. For more on that, see the
section later in this chapter titled “Validating HTML.”

Identifying property value problems ..............................................

What kind of error message do you get if you try to use a value that can’t work
with a particular property — such as assigning 12pxto the colorproperty?

If you feed this CSS code to the validator:

p
{
color: 12px;
text-align: center;
}

308 Part IV: Advanced CSS Techniques

Free download pdf