untitled

(John Hannent) #1
You get this excellent answer — both specific and accurate about the location:

Line: 3 Context : p
Invalid number : color 12px is not a color value : 12px

So you see, the validator can come through when it really wants to. And, cer-
tainly, validating your CSS code is most useful in two situations:

When you’ve tried reading through the code to debug it, but cannot
find the reason why your Web page is misbehaving or a style isn’t
working.(The default black headline style appears, even though you’re
trying to turn it green, for example.)
Just before you’re ready to publish your Web page on the Internet for
all to see. You want to find out whether any errors have slipped through.

Run your code through an HTML parser to ensure that you don’t have an
nasty surprises in that part of your Web page code either.

Sometimes, in the warning section, you’ll find a valuable suggestion. Consider
this possibility: You neglected to specify a background color for one of your
paragraphs of text. You did specify that the foreground (the text characters
themselves) should be dark green, and you assumed that the background
would remain the default white. But what about those people who’ve got
their own user style sheets turned on or are otherwise customizing their
browser’s behaviors and display characteristics? What if one of them has set
the background to a color that makes your dark green text pretty much
unreadable? The warning section of the validation report makes suggestions
about this kind of problem, and even if you ignore many of those suggestions,
at least you’re able to consider them and make an informed decision.

Validating HTML ..........................................................................................


HTML errors can sometimes cause CSS errors. And, of course, your Web page
is made up of both CSS and HTML, so you do need to test both types of code.
Fortunately, many HTML parsers (utilities that read through code to see if tag
pairs are matched, and so on) are available. Parser, validator, and debugger
are just synonyms for the same idea: letting you know whether your code
contains problems, potential (warnings) or real (errors).

I suggest you find a parser that’s a bit less — shall I say, authoritarian— than
the one offered by W3C. It criticizes lots of HTML code that works perfectly
well in Internet Explorer. However, if you want to get the full rigorous treat-
ment, here’s how to get a reading from W3C’s HTML debugger.

Chapter 17: Testing and Debugging 309

Free download pdf