HTML and CSS Reference
exception; this means browsers have to do extra work to parse and ren-
der it, which ultimately means invalid pages are slower to render. Also,
unless the particular structure of the invalid markup causes a browser
or tool to crash, bugs in the parsing and rendering of invalid markup
are less likely to be fixed than are those for valid markup. Subtle differ-
ences in parsing and rendering between browsers will eventually lead
to hard-to-discover cross-browser issues in web pages.
Finally, especially when you're learning, it's likely that you'll at some
point ask for help with something that isn't working the way you
expect. In most online communities that specialize in markup, the first
thing you'll be asked to do is fix any invalid markup, or at least explain
its existence. This is true for several reasons:
❂ As discussed in the previous point, invalid markup often leads to
❂ Error-checking tools are far more useful if they're pointing out one
major error in your markup rather than the major error buried in
hundreds of minor ones.
❂ If you haven't bothered to write valid markup, many members of
these online communities will view you as not worth their time and
effort to help.
To summarize, the three reasons why you should write valid markup
are as follows:
1 Invalid markup leads to subtle differences in parsing and rendering.
2 Browsers and development tools are optimized for valid markup.
3 It's easier to get help with valid markup.
Or, looked at from the perspective of why not to write invalid markup,
these three reasons can be rephrased:
1 You make things harder for yourself.
2 You make things harder for your tools.
3 You make it harder for others to help you.
You want to write valid markup, but how do you tell if your markup is
valid? In the final section, you'll learn about tools you can use to check