[whatwg] Configure Apache to send the right MIME type for XHTML
elharo at metalab.unc.edu
Wed Mar 7 10:14:25 PST 2007
Alexey Feldgendler wrote:
> If you are going to write XHTML documents whose DOM is not representable in HTML, then your documents won't be compatible with MSIE, and you won't need the described MIME type trick.
> OTOH, if you are going to restrict yourself to XHTML documents whose DOM is representable in HTML, then you might as well use HTML. It has been said many times here that virtually every single advantage that XHTML has over HTML4 is now also inherent to HTML5 (predictable DOM, processing with XSLT, etc).
Neither is really my point. The problem with malformed HTML is that it
has an inconsistent DOM. You get different DOMs in different browsers
and tools. Making a document well-formed XHTML gives you a consistent,
reproducible, predictable DOM.
If you go one step further and make the document valid strict XHTML, the
DOM gets even simpler and cleaner. Many nodes are pruned from the tree.
This makes it easier still to manage.
It's not about whether we can represent a DOM in HTML or not. It's about
consistency and simplicity.
I'm not the first to point this out by any means, but I don't think it's
been as widely recognized as it should. I suspect that's because many
developers working with HTML aren't really using the DOM at all. They're
hacking the text with IDs, document.write, innerHTML, and other tricks
that don't really pay attention to the tree structure of the document
they're working on. That may be a chicken-and-egg problem: as long as
the document is malformed even figuring out what the tree is is nearly
impossible and not cross-browser.
With HTML 5 parsers (which we don't have yet) the DOM of malformed
documents may yet become predictable, but it won't ever be obvious. And
it may well not be consistent across browsers unless Microsoft jumps on
board. By contrast, valid strict XHTML (probably transitional too) has a
reasonably consistent tree structure in all browsers today.
Once you achieve well-formedness you can begin looking at the document
in a new way. You get access to powerful tools like XPath and XSLT that
you didn't have before. You can start doing more than merely tossing the
page at a browser for rendering. And you don't have to wait for an HTML
5 parser to do it either. You can do it today with a large tool chain.
Elliotte Rusty Harold elharo at metalab.unc.edu
Java I/O 2nd Edition Just Published!
More information about the whatwg