I've been using XHTML for quite a while, maybe a year and a half or so. All that time, I've been serving it as text/html, mostly because I didn't know any better. Knowing nothing of XML at the time, I assumed that XHTML was the future and that of course I should use it. However, the problem with using XHTML at the moment is that XHTML should really be served as text/xml, for various reasons that Ian Hixie explains. Reading through that document, I feel like an Evil Person for serving XHTML as text/html for so long!
So why not just change to text/xml? Because a Major Browser (namely MSIE) doesn't support text/xml and wants to send files with that mime-type to another program. Much as I may be disgusted with that lack of support, I admit that it would be slightly premature to penalize MSIE for implementing a radical and new standard, not to mention the user-unfriendliness of effectively denying access to my second-biggest browser (biggest if you discount Phoenix, which is what I use, and most of my hits are from me). I still think IE bites, and I will continue to use (X)HTML and CSS that it doesn't support, but not at the expense of access.
So for the moment I've stuck code at the top of all my PHP files that will send IE the mime-type text/html and any other user-agent the mime-type text/xml. Basically it won't make much difference to anyone, except to people using something like Mozilla that actually checks the XHTML for well-formedness and then only in the event that I make a mistake.
On the plus side, I may have figured out why comment-cookies never seemed to work on my blog, nor on Burningbird's, nor on Kevin's. In XHTML, stuff inside <script> or <style> tags cannot be hidden from legacy browsers by commenting it out; a user-agent that understands XHTML will ignore everything inside the comments. So I've removed the comment tags, and we'll see if that works better.
In testing my mime-type hacking, I took a look at my front page in IE and was aghast at the styles... I hadn't realized that my using the CSS child selector messed things up so badly. I took it off everywhere it wasn't needed, except for blog paragraph styles, because it's so much easier to do what I want with that selector than without. (IE users: are you sure you don't want to use a super-fast, standards-compliant, shiny browser like Phoenix, or even Mozilla or Opera?)
On a related subject, Ian Hixie also explains XHTML 2.0 and why it's not evil just because it's not going to be used right away. As he says:
Do I expect XHTML2 to be used the moment it enters the Candidate Recommendation stage? Of course not! The fact that xHTML2 won't be widely used before the end of the decade is not a problem. For some reason, the Internet populous [sic] has this strange idea that if something isn't adopted overnight, it must be a failure. Things take time! You have to get the spec implemented, and you have to get the implementations into the hands of the public at large, before big sites will even consider switching to a new technology.
It's going to take a while for XHTML2 to be supported, especially because it ditches backwards compliance, but also because so far it's only a working draft. As he says, it'll be a long time before XHTML2 can be widely used. Aquarion thinks (or thought when he wrote that entry about six months ago) that non-backwards-compliance is the spawn of satan, but I think it's necessary. Sure, it would be nice to have everything still work, but HTML is an inherently screwed standard for all the reasons that XML is good and powerful. Since we're working up (or over) from HTML rather than back down from XML, stuff is going to get broken. That's unfortunate, but it has to happen some time, you know?
So while I'm using XHTML 1.0 right now (and serving it as text/html to the Stupid Browser), I'm seriously considering creating an alternate XHTML 2.0 version of the site. It might not be too hard with Movable Type, and it could be cool. I dunno, I'll probably play around with it at some point, before it gets widely implemented.
Laurabelle says:
I probably shouldn't be happy about this, but look! text/xml does make a difference, because I got a parsing error on this very entry! I feel somehow validated, that these little things do make a difference. :-)
Aquarion says:
Not spawn of satan, but possibly something less dangerous. Say, Spawn of Dick Dastardly? It's not that I'm against XHTML - or XML for that matter - it's more that I really don't think it's a good idea to completely move the foundations of a language within versions. Either XHTML 1 should never have happened, or XHTML 2 should be something like WebXML, a document format for presenting documents over the Web. Because there isn't one anymore. XHTML isn't designed for fine control over document positioning, and XHTML+CSS still has things that HTML4 does *better* schemantically (Like centering a picture, for example) And whilst schemantic web is all a very good thing, taking all the presentational bits out is leaving a gap whilst (and here is the vital bit) closing the standard from development in a differant direction.
If I thought I could make people listen, I'd start developing HTML5, which would take elements from XHTML1 (like the XML-Standard tagging), and keep developing it as a backwards-compatible language which we could actually develop the ambiguities out of.
Laurabelle says:
I do take your point about changing versions, but part of the effect of the XML in XHTML is that it does matter what version you're using, so as long as I have the proper doctype and DTD for my code, I'm fine. Unlike legacy browsers, XML-aware browsers will check the doctype declaration and interpret the page accordingly. This alleviates the need for backwards compatibility between versions of XHTML. I'm not saying consistency isn't good, but there are reasons to be inconsistent with a flawed standard.
And speaking of flawed standards, I suppose you and I will have to agree to disagree on the subject of HTML's advantages. While I agree that it would be nice to center images, I don't see visual bells and whistles as the point of web design. I didn't before, and these days I'm approaching life more and more through I see the power of the semantic web coming, of knowledge organization, of metadata, and I want to be there at the front, maybe even helping to determine what the semantic web will eventually look like.
Kevin says:
I think there's a need to be clearer about whether we're talking backwards compatibility or how well the code degrades.
In terms of backwards compatibility I'm inclined to stick two fingers up at those dragging their heels. Version 4.* was the last time both IE and Netscape claimed not to support XML and both have had 2 major version releases since then. That's just the big two, most of the less popular offerings have also claimed XML support for a while.
In the past we've handled backwards compatibility by using code which degrades gracefully. This meant we could support both legacy platforms and the reduced functionality of some more recent browsers like WebTV. Whilst I'm not bothered about the people using 3 year old browsers I do worry about the people who aren't even using a web browser as we tend to think of them.
Of course this leads into just what the web is/should be, but I've wibbled enough for now.
Btw, am I the only person who does images exactly the same in XHTML and HTML? A quick look at the spec doesn't show any obvious differences (okay, I admit to falling back on img and the transitional DTD but apart from the name of the tag nothing has changed.)
Laurabelle says:
As for alternative browsers, part of the idea of modularized XHTML and such is to make it easier for things like phones to access web content. You need to break things to fix them.
As for images, it depends on which version of XHTML. ;-)
Aquarion says:
You're supposed to use Object for images in HTML4, let alone XHTML.
My problem is one of forward compatibility. Not backwards.
HTML has always had one of the best forward-compatibility policies in the industry, in that if you don't understand a tag, render it as text. It's the thing that means that any browser (Back to Netscape 1) will render all of the text and information on the page in roughly the right way. A standard HTML supporting browser will (given the right http codes, since NS 1 doesn't support http1.1) render the page structually, no matter what version you use, from HTML 1 though to XHTML1.1. If you try to render an XHTML2 file in any browser that currently exists, however, all of the text will be rendered as one long string, with possible paragraph breaks depending on how you view them. Headings, sections, images and links will all just be plain text (no hyperlinks). Forms will be screwed beyond measure, thanks to the XForms thing. The document will, whilst still being readable, be nonsensical.
This is not a fundermentally bad thing. The same thing happens now if you render an RSS feed in IE, but this should not be an effect of a single revision number, given that HTML1-4 was followed directly by XHTML. If they were going to completely screw all previous browsers, the time to do it was with the new name, not the second revision.
My reason for not using XHTML 1, even, is a little plainer. I design sites which allow user submitted X/HTML in certian contexts (Counting me as a user in this case). I am not perfect, and the occasional fuckwits I get on sites that I've moderated for in the past are incapable of spelling "Validating HTML", let alone writing it, and I cannot let any site get into a state where the pages cannot be rendered because of a human HTML error, which is what happens if you make a mistake on any site served as content-type: text/xml. XML was designed so that humans wouldn't have to write it, so until the tools are available to make it invisible, I'm avoiding XHTML.
Laurabelle says:
Forwards/backwards compatibility depends on whether you're looking from the perspective of the old software or the new standard.
As for where they break it, I do understand your point, but I also think it would be hard to get anyone to use XHTML ever if they went straight from HTML to what will be XHTML2. Do you think they should have made HTML5 and then XHTML2 would be XHTML1?
I like writing my own code and will probably continue doing it even when there are XML tools that could do it for me. While I occasionally make mistakes, I check my posts when I make them, and I find it kind of fun that I get a real error when I make a mistake. Admittedly, I hadn't considered the fact that I some HTML in comments, and that users could break my page with cluelessness. At the moment I think my readership is small and clueful enough that I'll leave that capability until it becomes a problem.
Kevin says:
<img> is more than acceptable for both html4 and XHTML1. The tag will be replaced by <object> but it's not even slipped from the strict DTDs yet so it's perfectly valid.
Where most people produce invalid code and struggle most to align their images is by just putting them in as random content. Images, whether using img or object, are supposed to be used within appropriate tags. Once you start nesting them within <h*> or <p> tags either tag will validate to strict DTDs and extremely easy to align using stylesheets.
That's the correct way for both html and xhtml, it's just that with html (and possibly XHTML transitional) you could just place you image tags anywhere you liked (within reason) and the page would validate.
Oh, and for user input if you understandably don't want to write your own parser think about running something like Tidy to catch and correct errors. I guess there's still a problem with XHTML as anything it can't correct will still break, but for html input it's great.
Laurabelle says:
I think I may finally have fixed the remember-comments thing. (I found a MovableType tag in my external javascript file, which was quite silly, and I should have found it before.) This is a test. This is only a test.
Laurabelle says:
w00t!
Kevin's Home says:
Gaaargh Da Geeks!
Last night I was chatting to Laura when she made a simple comment about her website. This resulted in me
Laurabelle's Blog says:
Technical difficulties
Yesterday Maggie said her browser (Netscrape 4 on SunOS) was borking on text/html. So I tried to fix that and,