View Full Version : Xhtml
JackWolfgang
Wed., Jan. 19, 2005, 8:02 am
Is anyone writing XHTML 1.0 (http://www.w3.org/TR/xhtml1/#xhtml)?
If yes, are there advantages/disadvantages?
mrbelfry
Wed., Jan. 19, 2005, 10:11 am
I've been writing XHTML for about 18 months now and it is fairly easy because it is just valid HTML with some tags that have been deprecated. The major difference is that you have to nest and close your tags properly and also include a valid dtd thingy. I just copy this one:
<!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">
If you want to write XHTML then you should want to write valid XHTML which has all the benefits of valid HTML 4. The major advantage is that it is a sign that the industry really wants to get standardised and we should (in theory) see an end to different browsers rendering differently (although this is still dream). The next major browser war will probably be fought over CSS and security but I digress.
Everybody should be writing valid XHTML because it will mean (in theory) that your site will display across multiple platforms in a variety of different applications. It also means that I can tell my boss that I write XHTML and not HTML and it may convince him I can do things that an intelligent toddler can't!
JackWolfgang
Wed., Jan. 19, 2005, 10:33 pm
I've been writing XHTML for about 18 months now and it is fairly easy because it is just valid HTML with some tags that have been deprecated. The major difference is that you have to nest and close your tags properly and also include a valid dtd thingy.
The valid DTD is required for valid HTML 4.01 as well.
If you want to write XHTML then you should want to write valid XHTML which has all the benefits of valid HTML 4. The major advantage is that it is a sign that the industry really wants to get standardised and we should (in theory) see an end to different browsers rendering differently (although this is still dream). The next major browser war will probably be fought over CSS and security but I digress.
I wish. For example, this page (http://www.tristatecamp.org/working/TSCMenuTest.php) is Valid HTML 4.01 Transitional (http://validator.w3.org/check?verbose=1&uri=http%3A//www.tristatecamp.org/working/TSCMenuTest.php) and has a Valid external CSS (http://jigsaw.w3.org/css-validator/validator?profile=css2&warning=2&uri=http%3A//www.tristatecamp.org/working/TSCMenuTest.php), but it displays differently in Firefox 1.0 and IE 6.
Everybody should be writing valid XHTML because it will mean (in theory) that your site will display across multiple platforms in a variety of different applications. It also means that I can tell my boss that I write XHTML and not HTML and it may convince him I can do things that an intelligent toddler can't!
As should valid HTML.
The reason I am reluctant to switch is I have heard some browsers have problems with displaying XHTML unless you apply some hacks to config files on the server.
JackWolfgang
Sat., Jan. 22, 2005, 8:17 pm
I wrote my first XHTML the other day for a Blogger Template. Very interesting, and not much more difficult than HTML. However, the blog doesn't validate because Blogger doesn't encode it's ampersands (i.e. it uses & in URLs as opposed to & ).
Faithhb_lutheran
Tue., Aug. 2, 2005, 4:23 pm
I use xhtml to do text pages to keep myself more standards campliant. also I am currently trying to set up a dual site for mobile users the software they have is made from xml so xhtml actually loads quicker and has the added benifit of being smaller most os the time.
xhtml
Sun., Mar. 12, 2006, 9:03 am
There are many misconceptions about using XHTML for web pages and a huge debate is going on right now in the developer community about whether it should be used at all for web sites - given the lack of support in the current browsers.
Yes, I know that the current trend is to use XHTML, with CMS and some developer applications - but as many of you have discovered - this seldom works as advertised.
I jumped on the XHTML bandwagon all most as fast as the W3C finalized the specifications, but like a so many others, it took me a long time to discover all the facts about using it, and now have gone back to using only HTML 4.01 Strict for sites I work on.
I do think that XHTML is a better route for learning HTML markup since it is stricter than HTML, but as far as actually using it on web site - it may not be a good idea.
Here are some really important points to consider if you go the XHTML route:
1. Being standards compliant and/or using CSS does not require using XHTML. Properly marked up and valid HTML/CSS is standards compliant. CSS was developed to go hand-in-hand with HTML 4 - XHTML came later. It is surprising how many people think that to use CSS you must use XHTML.
2. Although XHTML 1.0 looks like HTML 4.01 it is not the same thing. XHTML is a "reformulation of HTML as XML" and is designed to be used by XML parsers. All markup must be well-formed and valid or the page will not be rendered at all by a XML compliant browser, when the page is served with the correct MIME type of application/xhtml+xml. HTML pages are served with the MIME type of text/html by default.
3. Although XHTML may be served as text/html for "backward compatibility" when you do this, you are actually sending the browser invalid HTML! The emply elements like "<br />", "<img ... />" are not valid HTML and rely on the browsers error correction to display properly. If all browsers actually following the HTML specs, they would be spitting out ">" characters all over your pages!
4. The most used (and buggiest) graphical web browser "Internet Exploder" does not understand XHTML at all (even the forth-coming Version 7 will not) when the page is served with the correct MIME type of application/xhtml+xml. IE will attempt to download the page rather than display it. You can see a demonstration of this by using this link: XHTML test page (http://www.hfrhost.com/%7Eevasser/test.xhtml). After attempting to view the page in IE, try it with Firefox or Opera (the only Windows browsers that do support XHTML). When XHTML pages are served as text/html, IE simply reads the page as invalid HTML and does its error correction.
5. Some CSS displays differently in XHTML than in HTML and some elements are handled differently. That's why some folks mention that pages marked up with CSS sometimes look a little different in XHTML than in HTML. Also some JavaScript functions like document.write() will not work in properly served XHMTL.
6. Finally, you should also be aware that XHTML 1.0/XHTML 1.1 are not forward compatible with the proposed XHTML 2! XHTML 2 will be a horse of a different color that does away with many existing elements such as <img> and there will no longer be <h1>,<h2>,etc. elements but only an <h> element; to mention just a few changes. No need to worry about that now - if the spec is finialized, it will be years before there are browsers that will be able to read it.
There are many other "gotchas" that pertain to using XHTML (properly) and I won't go into them here, but I wanted to add my two cents worth to this discussion, by pointing out some of them.
My personal recommendation (and that of many of the so-called HTML Guru's) is to use HTML 4.01 Strict but use XHTML coding style (what I like to call HTML+) thus:
All element tags and attributes in lower-case)
Close all elements such as <p></p> <li></li>, etc. NOTE: This doesn't mean using " />" on empty elements such as <br>).
Quote all attributes such as <img width="100" height="50" alt="">.
Include alt attributes on all images and don't use deprecated or none existant elements (such as <embed> - see the HTML 4.01 (http://www.w3.org/TR/html4/) specs).
Be sure all your ampersands are encoded properly "&" and not just "&"
And most important - use the correct <!DOCTYPE> (Strict not Transitional or Heaven forbid - Frameset) and be sure your pages and CSS are valid!
Ultimately, it's up to you, the web coder, which route you want to take XHTML or HTML. As it stands right now, there is no advantage what so ever to serving your web pages as XHTML, but it does no harm either, if served as text/html.
I'll be surprised if I don't get a lot of comments on this post!
David Gillaspey
Sun., Mar. 12, 2006, 11:41 am
Hi Ed,
Wow, thanks for your insightful comments about XHTML.
I recently read Eric and Elisabeth Freeman's Head First HTML With CSS & XHTML (http://www.amazon.com/gp/product/059610197X) (O'Reilly, 2005) ? which I can recommend to all ? which helped me get up to speed on web standards (intellectually, at least; in a few months I'll attempt to actually apply what I learned to my own site). But, every new technology or standard has its pluses and minuses, so it's always good to get the "full story" about it, as you have provided us.
Sincerely,
David Gillaspey
President
Great Church Websites
& forum administrator
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.