Scripsit Ben C:
- -
They're equal in those terms. It was your parenthetical remark I was
disagreeing with.
I find that strange, since the parenthetic remark is just an attempt at
a humorous clarification of something that was said previously; it does
not add any new factual statement.
But what is the purpose of validation?
I think I already answered that: to avoid some stupid mistakes.
Often because you intend to use
your markup as the input to some computer program one of whose implied
preconditions is that its input consist of a valid document according
to one or other from a set of particular DTDs.
You're trying to refer to browsers, aren't you? But you're not actually
describing how they behave.
Try it. Use different DTDs and see how much browsers care.
My understanding of a modern browser is basically
this:
1. The HTML is parsed and the result is a DOM tree.
2. The DOM tree is rendered according to the CSS specification (taking
into account any styles you set).
3. The DOM tree can be further manipulated by JS.
That's an idealistic description, but let's suppose that browsers really
do that. Now where does the DTD or validation come into the picture?
I just tried P inside SPAN in Firefox out of interest and it just
gives me a DOM tree containing a P inside a SPAN, so nothing
unpredictable there. Not a good example then.
So it really couldn't care less about the DTD, could it? A more advanced
browser could infer a missing </span> tag when it encounters a <p> tag
and a SPAN element is open, but this is a quality issue, about error
handling quality.
Here is a better one:
<table>
Tables aren't a good example of anything in this area, since tables are
processed in quite idiosyncratic ways, with lots of adhockery and
kludgery.
That's one of those stupid mistakes that validators catch. I think we
have no disagreement on that.
Now, if I didn't validate, I might expect to get this DOM tree
(fragment):
Whether you validate or not, it's a mistake and, in practice, results on
"hello" thrown in into the presentation in some odd place, probably
before or after the entire table. That's because browsers have been
"hard-wired" to process table markup in specific ways.
Of course this implies that you should use markup that meets browsers'
expectations, and validation may help you there. But _any_ DTD will do,
as long as the language described by it meets those expectations. You
don't have to use a specific W3C DTD for that (still less a specific
doctype declaration, even though the HTML 4.01 and XHTML 1.0
specifications prescribe that here are the three doctypes among which
thou shalt choose)
In fact, using a non-W3C DTD is _better_ for such purposes as well. The
reason is that browsers may get wild if some end tags that are omissible
according to HTML 4.01 DTDs are omitted. It can thus be useful to make
the end tag required in your DTD. (Using XHTML 1.0 DTD would solve this
in a different way, but the most popular browser is really not prepared
to XHTML, even though it can deal with XHTML written according to
Appendix C, but does this make much sense? You _don't_ have to use XHTML
1.0 just because you want to close all elements explicitly.)