[thelist] XHTML or HTML WAS Good Examples of XHTML Usage

Timothy J. Luoma luomat at operamail.com
Thu Sep 4 10:30:38 CDT 2003


For those of you looking for a summary at the top, here it is:

So what would I teach?

I would teach XHTML + how to use a validator.

XHTML because I believe the forced closing of tags is a good thing.  It 
makes you write better code and makes it easier to find mistakes.  Plus 
you have the option of sending it as text/xml and seeing parsing errors 
even before you hit the validator.  If you are working in an environment 
which allows tight control over what browsers are used, you can install a 
XHTML capable browser (latest Opera and Mozilla... not IE6) and use 
text/xml.

For teaching purposes, learning XHTML makes understanding XML syntax a 
much smaller step.  You already have lowercase tags and matching tags 
under your belt.


For those of you who want the full response, here it is



<blockquote cite="http://www.meyerweb.com/eric/comment/chech.html">
<p>
There are those cases where such essays are written because the author 
enjoys grandstanding, and knows that use of the "considered harmful" 
format will get them noticed.
...
Typically, "considered harmful" essays gets written because someone has an 
axe to grind, and they feel like making that grinding process both public 
and dogmatic. This is a form of grandstanding, of course, but it is done 
with a purpose beyond simple publicity seeking. Usually such "considered 
harmful" essays are intended to draw attention to a little-known subject 
about which the author is passionate, or to highlight what the author 
feels to be a poor decision by someone else.
...
In the main, however, it often seems that "considered harmful" essays get 
written simply because an author can't think of a better way to express 
his point of view.
</p>
</blockquote>

The rest of the article is worth reading too.

Now, with that in mind, let's address http://www.hixie.ch/advocacy/xhtml

> Current UAs are HTML user agents (at best) and certainly not XHTML
> user agents (certainly not when sent as text/html), so if you send
> them XHTML you are sending them content in a language which is not
> native to them, and relying on their error handling.

Show me a browser that can handle HTML and not XHTML.

> * <script> and <style> elements in XHTML may not have their contents
> commented out, a trick frequently used in HTML documents to hide
> the contents of such elements from legacy UAs. [1]

Sure they can, you just have to do it the right way instead of the old way.


> * XHTML documents that use the "/>" notation, as in "<link />", are
> not valid HTML documents. (See the third bullet point in the
> section entitled "The Myth of "HTML-compatible XHTML 1.0
> documents"".)

Show me a browser that can't handle <link /> but can handle <link>


> * Document sent as text/html are handled as tag soup [2] by most UAs.
> Since most authors only check their documents using one or two UAs,
> rather than using a validator, this means that authors are not
> checking for validity, and thus most XHTML documents on the web now
> are invalid.

I dispute this claim.  Where is the data backing it up?

I would argue that most people who bother going to the extent of using 
XHTML care enough to use a validator.

> Therefore the main advantage of using XHTML, that it
> has to be valid, is lost if the document is then sent as text/html.
> (Yes, I said _most_ authors. If you are one of the few authors who
> understands how to avoid the issues raised in this document and
> does validate all their markup, then this document probably does
> not apply to you -- see Appendix B.)

I would say <em>one</em> advantage is lost, but it is not the main one, to 
me.

> * If you ever switch your XHTML documents from text/html to text/xml,
> then you will in all likelyhood end up with a considerable number
> of XML errors, meaning your content won't be readable by users.

If you do decide to switch to text/xml, it will be so many years down the 
road that IE 6 is no longer an issue.

You will only get errors then if you have errors now.  So validate.  (You 
need to do that with HTML4 too.)

By the way, spell checking is also not included in XHTML either, so you 
will have to keep working on spelling things correctly.

> (Most XHTML documents do not validate.)

Most statements made in "Considered Harmful" documents are opinions not 
based on facts.


> * A CSS stylesheet written for an HTML document is interpreted
> slightly differently in an XHTML context (e.g. the <body> element
> is not magical in XHTML, tag names must be written in lowercase in
> XHTML).

If you are writing XHTML, you are probably aware of that when you write 
CSS.

> * A DOM-based script written for an HTML document has subtly
> different semantics in an XHTML context (e.g. element names are
> case insensitive and returned in uppercase in HTML, case sensitive
> and always lowercase in XHTML).

Hrm.  So in HTML I have case insensitivity or UPPERCASE, but in XHTML I 
always have lowercase.  Great, I'll use XHTML!

> * If a user saves an XHTML-as-text/html document to disk and later
> reopens it locally, triggering the content type sniffing code since
> filesystems typically do not include file type information, the
> document could be reopened as XML, potentially resulting in
> validation errors, parsing differences, or styling differences.

HUH?

If I send a document as text/html, you know what it will get saved as?  
HTML!  WHOA!

And what is this "filesystems typically do not include file type 
information"?

I saved http://www.hixie.ch/advocacy/xhtml in IE6, Opera7.2 and 
MozFirebird (recent nightly).

IE6 and Opera saved it with .html at the end (well, IE used .htm)

MozFirebird saved it as "xhtml" (very hardcore, well done fellas)

Perhaps I should write an article "Not using file extensions considered 
harmful"

"The document could be reopened as XML" -- only likely if the person saved 
it as .xml or similar.  Most times it will not be.

And again, the validation errors shouldn't be there regardless of what 
language you are using.

> * The only real advantage to using XHTML rather than HTML is that it
> is then possible to use XML tools with it. However, if tools are
> being used, then the same tools might as well produce HTML for you.

XHTML is easier to parse than HTML because you have forced closing tags.  
HTML doesn't require them.

> Alternatively, the tools could take SGML as input instead of XML.

Alternatively the world could be different than it is.  But it isn't.

> * HTML 4.01 contains everything that XHTML 1.0 contains, so there is
> little reason to use XHTML in the real world. It appears the main
> reason is simply "jumping on the bandwagon" of using the latest and
> (perceived) greatest thing.

This may be true.  Can I give you a list of compelling reasons today to 
use XHTML?  No.  But I also don't buy the hysteria around sending XHTML as 
text/html.

Again, folks, read the specs:

<blockquote 
cite="http://www.w3.org/TR/2002/NOTE-xhtml-media-types-20020801/">
<p>
This document summarizes the best current practice for using various 
Internet media types for serving various XHTML Family documents. In 
summary, 'application/xhtml+xml' SHOULD be used for XHTML Family 
documents, and the use of 'text/html' SHOULD be limited to HTML-compatible 
XHTML 1.0 documents. 'application/xml' and 'text/xml' MAY also be used, 
but whenever appropriate, 'application/xhtml+xml' SHOULD be used rather 
than those generic XML media types.
</p>
</blockquote>

Yeah I know he says that HTML compatible XHTML is a myth.  Again, show me 
a real world example of it breaking anywhere.

The specs[1] say that XHTML 1.0 "may" be sent as text/html.  Anyone who 
says differently is wrong.

http://www.w3.org/TR/2002/NOTE-xhtml-media-types-20020801/#summary


The whole article seems to have a lot of strong feelings, but almost no 
data to back up any of the claims made.  Several of them are just 
nonsense.  Most of the arguments are "this bad thing might happen" but in 
reality I can't imagine any of them happening, especially if you are 
validating, which you should be doing regardless of whether you use XHTML 
or HTML.


So what would I teach?

I would teach XHTML + how to use a validator.

XHTML because I believe the forced closing of tags is a good thing.  It 
makes you write better code and makes it easier to find mistakes.  Plus 
you have the option of sending it as text/xml and seeing parsing errors 
even before you hit the validator.  If you are working in an environment 
which allows tight control over what browsers are used, you can install a 
XHTML capable browser (latest Opera and Mozilla... not IE6) and use 
text/xml.

For teaching purposes, learning XHTML makes understanding XML syntax a 
much smaller step.  You already have lowercase tags and matching tags 
under your belt.

TjL


More information about the thelist mailing list