To XHTML or not to XHTML - discussion of cons of using XHTML
There's a very good discussion on the pros and cons of using xhtml, give it a read if you've just sort of blindly accepted what the W3C is telling you to do, this is one of the more coherently rational arguments against using XHTML I've ever come across.
The idea of XHTML is nice, but: :: Quote :: There are few advantages to using XHTML if you are sending the content
as text/html, and many disadvantages. In addition, currently, the majority (over 90% by most counts) of the UA market is unable to correctly render real XHTML content sent as text/xml (or other XML MIME types). For example, point IE at: www.mozillaquestquest.com/ Only Mozilla, Mozilla-based browsers such as Netscape 6 and 7, recent versions of Opera, and Safari, are able to correctly render that site. (IE6 shows a DOM tree!) Authors who are not willing to use one of the XML MIME types should stick to writing valid HTML 4.01 for the time being. Once user agents that support XML and XHTML sent as one of the XML MIME types are widespread, then authors may reconsider learning and using XHTML. Anyway, if you want to stop following the hype, give this some serious thought. So, I can see you asking, so why are almost all your sites in XHTML 1 transitional or strict? Because just like there is no real reason to use XHTML, there is also no real reason to not use it that I can see. All HTML will be parsed by your browser, by any user agent out there, as tag soup, so who cares what you call it? The only difference the doctype declaration makes is that it forces certain browsers to go into quirks mode, like IE 6, Mozilla based ones, etc. Quirks mode is different with each browser, in IE 6 it just makes the page render as if it were following the Microsoft IE 5x box model, the one that actually makes sense that is, not the W3C one, that came from the print world [ hello W3C.... the web is not a print medium, it's a liquid medium, you really messed this one up, oh well... ] There's one plus too with XHTML, if you ever decide to switch your content over to some kind of XML schema, it's ready to go, no modifications are needed. That advantage only applies in the case of switching content over to xml, switching it back can involve any kind of output you want through something lie XSLT. However, note that not all character entities, like are supported without a doctype in xml, so in many cases even this advantage won't be real. The real plus, however, is really simple: when you create a valid html document, 4.01 strict or transitional, XHTML 1.0 strict or transitional, you can debug the document using something like the w3.org html validator. This is really useful, helps me and everyone I work with find display errors all the time, that alone makes putting out validating code worthwhile, but, again, note, it's irrelevant what type of code that is, as long as you code to the doctype specifications, it makes no difference which you use. Back to top |
|||||
More on IE quirks mode
For those of you wondering, this is the differences:
:: Code :: <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> this is the exact way you are told to do it. Problem? Triggers quirks mode in IE 6 because the doctype is not the exact first line of the docyument, <?xml version="1.0" ?> is. And this xml version declaration also triggers errors on php pages unless you write out the xml declaration on page load with echo statement, like: :: Code :: <?php echo "<?xml version=\"1.0\" ?>\n" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> This will make it work in PHP but not in IE 6, so just forget the xml declaration unless you really know what you are doing, and are actually delivering text/xml type documents, and know what that entails, in which case you most probably don't need any advice on anything related to this subject. :: Code :: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> Will work fine, for xhtml and html 4, IE 6 will handle this fine, treat document as a non quirks mode html page, means it will apply W3C box model to css elements, table cells, etc. :: Code :: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">This one line doctype will trigger quirks mode, the "http://www.w3.org/TR/html4/strict.dtd" part is not optional. However, this can be useful because the page will validate fine with this single line version, no url, but will run as quirks mode, which sometimes is what you want, for instance, Mozilla puts extra spaces in table cells in non quirks mode, but not in quirks mode, and if you just want the page to display right, this is a quick fix. Keep in mind that this stuff just doesn't matter in any real world sense, check your favorite non geek sites and see how many either validate with zero errors, or even use a doctype. Why not use a doctype? Because it doesn't matter, to be honest, the only thing it affects is how the page renders re certain quirks/non quirks browser behaviors. Back to top |
|||||
Thanks for bringing that up, Erik, here's a full list of all the current doctypes, note that only XHTML requires that you change the <html> to this:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">, here's the full doctype list: :: Code :: DTD List
HTML 2.0 - DTD: <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN"> HTML 3.2 - DTD: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> HTML 4.01 - Strict, Transitional, Frameset: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> XHTML 1.0 - Strict, Transitional, Frameset: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> XHTML 1.1 - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> MathML 1.01 - DTD: <!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd"> MathML 2.0 - DTD: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd"> XHTML + MathML + SVG - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> SVG 1.0 - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> SVG 1.1 Full - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> SVG 1.1 Basic - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd"> SVG 1.1 Tiny - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd"> XHTML + MathML + SVG Profile (XHTML as the host language) - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> XHTML + MathML + SVG Profile (Using SVG as the host) - DTD: <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> List of DTDs for the CSS validator. Authoring tools MUST NOT use the following list. HTML 4.0 http://www.w3.org/TR/1998/REC-html40-19980424/strict.dtd http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd http://www.w3.org/TR/1998/REC-html40-19980424/frameset.dtd HTML 4.01 http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd XHTML 1.0 http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-frameset.dtd XHTML 1.1 http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11.dtd Template <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> That should help clarify how to do it for users, of course, this replaces this: <html> <head> etc in the case of XHTML, in other HTMLs it is just added before the <html>, the first line of the document. Back to top |
|||||
Very educational thread here. I've been thinking about going to XHTML lately, but I really can't on my own site due to my third-party scripts. I may give XHTML a shot when I design my next new site. Out of curiousity, how difficult is the switch from HTML 4.01 Strict (what I currently use) to XHTML 1.1? From what I hear, that switch won't be nearly as difficult as the switch from XHTML 1.1 to XHTML 2 when it comes out.
Back to top |
|||||
Problems using XHTML
This is from the frequently cited overview of XHTML problems
:: Quote :: Note that this document compares XHTML 1.0 compliant to appendix C to HTML 4.01, because that is the only variant of XHTML that may be sent as text/html.
Executive Summary ----------------- If you use XHTML, you should deliver it with the application/xhtml+xml MIME type. If you do not do so, you should use HTML4 instead of XHTML. The alternative, using XHTML but delivering it as text/html, causes numerous problems that are outlined below. Unfortunately, IE6 does not support application/xhtml+xml (in fact, it does not support XHTML at all). In fact, we just tried delivering the pages of techpatterns.com as mimetype application/xhtml+xml using this method, which involves detecting browser support for the mimetype at the header phase, then declaring it mimetype application/xhtml+xml if the browser supports it. All well and good, but as this article points out: :: Quote :: As to why I’m not using XHTML 1.1 anymore, well, I’ve tried it on several occasions for varying lengths of time, and I’ve come to the inescapable conclusion that it’s a pain in the a#@ with no demonstrable benefit. XHTML 1.1 is only supposed to be served with a MIME type of application/xhtml+xml (serving it as text/html is evil), but the application/xhtml+xml MIME type is completely unsupported in Internet Explorer and has nasty side effects in Mozilla.So if you are thinking of using XHTML 1.1, it must be mimetype application/xhtml+xml , it's not optional. The problem? :: Quote :: Scripts that use document.write() will not work in XHTML contexts. (You have to use DOM Core methods.)And this is exactly what we found. All pages with any invalid markup at all fail to parse, return a parse error page, nothing else. Opera 7.5, to its perhaps credit, break the standards and actually let you do document.write with javascript. Mozilla, to its greater credit, does not execute document write at all, which is correct, but annoying, since the workaround for not using document.write is a huge pain in the butt, and probably not backwards compatible. Back to top |
|||||
:: Quote :: The only difference the doctype declaration makes is that it forces certain browsers to go into quirks mode, like IE 6, Mozilla based ones, etc. Quirks mode is different with each browser, in IE 6 it just makes the page render as if it were following the Microsoft IE 5x box model, the one that actually makes sense that is, not the W3C one, that came from the print world [ hello W3C.... the web is not a print medium, it's a liquid medium, you really messed this one up, oh well... ] Thanks - I needed that, and you made my day! I've been feeling as if I'm the only one out there, notwithstanding a couple of folks on another board we know and love (or not....) Back to top |
|||||
:: Quote :: I've been feeling as if I'm the only one out thereNo, you're not the only one out there, 99.99% of the web is there with you. Sometimes that simple fact gets hard to see when you're only talking to the 0.01% that has difficulty recognizing this fact. There are some really funny things written about this, my favorite was the guy who went out and tested a bunch of XHTML sites and found only one that actually was correct mime type and error free. There's others now, techpatterns and phoenixwebtech both validate as correct mimetype, but only phoenixwebtech serves that to non validators since techpatterns uses a lot of document.write type javascript to function. It was actually a really sharp poster on another forum, one of my favorites, who consistently pointed this fact out, it took a while to register in my brain that this guy really knows what he's talking about. His stuff on the 'semantic web' is equally enlightening, by the way. I made a whole network of client sites in XHTML 1.0 transitional, but even as I was making them, for portolio purposes only, I always felt kind of guilty about doing that, but I also really did sort of believe that it was somehow better. The last ones I did were in XHTML 1.0 strict, I thought that would be better, it was right before I learned the stuff talked about in this thread, that was the last one, though I'll still do it if I get a client foolish enough to think that has any meaning or value. To be honest, when I first tried this stuff, I found that it was easier to create a valid xhtml document than a HTML 4.0 strict document, but I guess I've learned something along the way, now it's six of one, half a dozen of the other as far as I'm concerned. Some of the links above are really funny, there's one blog where the guy points out that one of the main XHTML advocate's blog would have crashed if he had actually done an RMS feed from it, can't remember the specifics, but it was pretty funny. We do an actual XHTML 1.1 site, the real thing, real mime type application/xhtml+xml, there is as one of the quotes above said, no demonstrable benefit, zero, zip. www.phoenixwebtech.com is it, that's our web design site. [resize it, it's fun to watch it all move around] I've now started doing client sites in either HTML 4.01 strict or transitional, depending on the specifications, but even there if frames are required, they are not declared with doctype at all, since you can't make a frame without borders that will validate in any doctype as far as I know, maybe 3.2, but then you run into other errors, so I just make that <html> and leave it at that. Most stuff I do doesn't depend on quirks mode for display correctness anyway, so it's actually not an issue in most cases. Back to top |
|||||
I get snappish over "this validates to THAT spec" anyway - whatthehell does it matter to WHAT it validates if the site's unusable?
Of course, this leaves out of the equation entirely the se philosophiles.... and I'm getting a bit tired of all that m'self! Back to top |
|||||
:: Quote :: whatthehell does it matter to WHAT it validates if the site's unusable?.... Of course, this leaves out of the equation entirely the se philosophilesHa ha, that's what I found too, the more I concentrated on getting perfect code the less content I found myself generating. HTML is really a beautiful little language, the world absolutely loved it, it was and is simple, clean, and efficient. Then rather than pay attention to the world, these guys like Bernards-Lee or whatever his name is decided that, no, we can make it better, we know what's best. A lot of people might say, hey, it was an open public discussion, you could have given some input, but only the most hardcore geeks are going to do that, and the world they want, I don't know, it's not the world I want I guess. When you spend too many years programming and living in a programmed world it messes with your head. 'se philosophiles' - what's that referring to? People who think perfect markup will give them better rankings? That's a funny one, in almost all cases what gave them the perceived better rankings is simply that they did a full site update, search engines like that. And a really silly claim too, any search for target key words will show you tabled site after tabled site, filled with <font size=7>Header text</font> type markup. For me, valid code has 2 really important uses: 1 - it gives you something to use to debug page code, like a debugger in programming languages. 2 - it makes sites a lot easier to maintain longterm, this is a huge factor which I really appreciate. my personal theory is that there's a lot of people out there, mostly young, who have grown up in front of their monitors, and they really really want the stuff to have some greater meaning, meaning they really should get from the real world, so they jump on these bandwagons, really believe in the stuff, but it's just markup language, or ways to style your content, the content is what you should worry about first, but a lot of these people don't have much to say I think outside of the box. That gets pretty old. Back to top |
|||||
:: jeffd wrote :: For me, valid code has 2 really important uses:
1 - it gives you something to use to debug page code, like a debugger in programming languages. 2 - it makes sites a lot easier to maintain longterm, this is a huge factor which I really appreciate. Yes. BECAUSE html is simply "another programming language". It's the orphan because it has NOT had a "debugger" until the advent of "validation". Validation IS the debugger for html. Not a really hard thing to grasp, is it? :: Quote :: my personal theory is that there's a lot of people out there, mostly young, who have grown up in front of their monitors, and they really really want the stuff to have some greater meaning, meaning they really should get from the real world, so they jump on these bandwagons, really believe in the stuff, but it's just markup language, or ways to style your content, the content is what you should worry about first, but a lot of these people don't have much to say I think outside of the box. That gets pretty old.Well, I grew up in the 60s - flower children, free love, communes, and VietNam.... but I didn't buy into all that - I've been a card-carrying member of the Establishment since I don't even know when - embryonic stage? Probably.... THERE IS NO LARGER MEANING. The net is a fluid non-living organism (now if THAT'S not a contradiction in terms, I don't know what IS!) and will change on a micro-milliseconds basis - so how is anyone going to keep on top of it? They aren't. There IS no top, bottom, be-all, or end-all. And y'know what else? That's JUST GREAT. 'bout time there was something out there which didn't play by any rules anywhere! [Er. In case you didn't know beforehand, my middle name is "iconoclast"....] Back to top |
|||||
All times are GMT - 8 Hours
|