Everybody is talking about why you “should” serve your XTML pages as “application/xml” or something similar. I really think that they are missing the point.
In my opinion the most important reason for promoting and using XHTML is not that it is XML and therefore inherits all the programming possibilities. The main reason is the coding practice that follows from its use.
Writing user-friendly (read developer friendly) code is the most important issue here. And not the fact that you can write valid code that adheres to some scheme or DTD.
Getting your code to validate is just as fun and enlightening as beating your head against the wall.
Everybody relax; getting your pages to validate is not the main goal. It is a means to an end.
But before we get there, we should learn to write easy to maintain code. This will make things easier to debug in search for validation errors if we want to get validated code.
Coding your pages in XHTML “must” mean that you write semantic code and try to separate content from presentation. Most people tend to apply a few simple rules (close your FONT tags!!) to generate a valid impression of XHTML. But unfortunately they are completely missing the point. (Though this will get them the goodies that come from using XML syntax.)
XHTML is rich and can really add meaning to a document. The presentation from Tantek emphasizes this and shows that the tags are really designed to tell the developer the contents purpose inside an element. (Remember that XML was designed for humans and machines.)
It is the same thing when you write code in PHP, VB or Java. Most of the time you use a naming convention for your variables and functions. Just to make it a bit more easy to read and understand.
Ever read some code that uses function names like: function do_aRt() or variable names like var aRt_01 ? Doesn’t make sense, does it?
That is why they invented the Hungarian notation, or camelcase for writing more developer friendly class names and variables.
It makes things much easier if you want to review your code after a year.
Same thing counts for XHTML. If you use descriptive elements, things will be so much easier to read and to maintain your code (assuming that you read your code).
The following is just an example to make things a bit clearer.
Suppose you are hired to do the layout for a Chinese or Arabic website. You get to write the HTML templates and the CSS files, based on the existing website.
The first view on the code shows me tagsoup, with several nested tables and a few DIV’s and FONT tags. Where to start?
If the previous developer used tables for layout and never added the slightest indication of what the function of the content was, you are lost.
Back to the owners and request a detailed wireframe in English!
Start with really thinking about the content that you are trying to display and maybe 1 of the 91 tags could add some meaning to that. The Markup reference from Mozilla really does a good job with adding good semantics to existing tags. And of course read the SimpleQuiz from Dan Cederholm.
Yes, the coding practice IS the main reason for using XHTML (as tagsoup). People write propper code, throw unnecessary elements out of the window and think about using semantically relevant elements. So I think too, theres no harm to a website, when using XHTML as tagsoup.
I couldn’t agree more, well said. There are so many purists out there that claim you shouldn’t use XHTML at all unless every browser starts suddenly supporting it. In my mind the goal is to advocate clean markup by using it now, and the more people follow suit, the sooner the Web will start improving. There are ungodly amounts of bad sites out there, and it is my belief this stems entirely from browsers that are designed to allow laziness on the part of developers.
I know what you mean, but people will not understand if you talk about HTML.
Cause isn’t that what they all did the last 5 years?
Promoting HTML, but calling it XHTML is not a bad thing (that is what I’m doing).
Most website are not even ready for the basics: semantic HTML code.
So XHTML and making adjustments to server settings is the right thing to do, but probably not possible in the near future.
COMMENT:
I’m actually advocating HTML. (And with that I don’t mean tag soup.)
We should definitely NOT use XHTML as tagsoup.
Stick to simple and semantic code, whatever you plan to use, HTML or XHTML.