Neredbojias said:
I think this whole thing is just an example of an
invalid argument.
When scripting a web page you are scripting a document object model
created by the browser. If the document is an HTML document (including
tag soup) the browser will create an HTML DOM and when the document of
(real) XHTML the browser (assuming it can handle the document at all)
will create an XHTML DOM.
The two types of DOM are structurally similar but need handling in
different ways. HTML DOMs are case insensitive, disinterested in
namespaces, prefer direct setting of Element properties over the use of
the setAttribute method and provide numerous 'shortcut' properties. On
the other hand XHTML DOMs are case sensitive, require the use of
namespace qualified methods, prefer the use of setAttribute to property
assignment and tend not to provide 'shortcut' properties not explicitly
required by the W3C DOM specifications.
Very few non-trivial scripts are capable of operating with both HTML
DOMs and XHTML DOMs. One of the practical differences between the two
types of DOM is that in XHTML DOMs the document.write method is
unusable. It either fails silently (e.g. in Opera 7+) or they throw
exceptions (Mozilla). So it isn't really a question of whether
document.write is in some sense 'appropriate', but more a practical
consideration; it will not work in at least a significant proportion (if
not all) XHTML DOMs.
If mark-up is created as XHTML (preferably 1.0, Appendix C) and served
as text/html the browser (not unreasonably) assumes that the content
type is definitive and tag-soups the mark-up into an HTML DOM. The
result can happily be scripted as an HTML DOM (because it is), but that
script stands a really good chance of failing utterly in the event that
the same mark-up ever is interpreted as XHTML. And that is virtually
guaranteed to be true if the script uses document.write.
If the scripting of a document depends entirely on that document being
interpreted as an HTML document (and/or HTML tag soup), so that an HTML
DOM will be created to be scripted, many arguments for using mark-up
that resembles XHTML evaporate. For example, there is no 'future
proofing' in such mark-up because if the future ever allows the same
document to be served as XHTML its accompanying scripts would need to be
totally re-worked.
Richard.