Hi, I've been coding my page using XHTML Strict DTD, but I've read that if you don't have to use XHTML, you shouldn't. And I'm pretty sure now that I don't need it.
My site uses CSS, Javascript, and Spry (which I believe is just the usage of CSS and Javascript together), and that's about it.
When would you need to use XHTML?
And is it recommended to switch to HTML if XHTML is not needed? Is it worth the extra work?
I use xhtml strict only now. I used to think html was the way to go, but after a little reading on it decided to switch over. It really depends on what your needs and wants are. Here's how I see it.
HTML Advantages
-Slightly easier to write
-Very lenient on coding errors (HTML parser will correctly close unclosed tags, etc).
-Compatible with all browsers.
XHTML Advantages
-Significantly more strict on coding errors (This is an advantage for some people like me, makes fixing problems much easier if code is valid).
-Faster parse time (if served as XML to supporting browsers).
-It's XML. It means you can define custom tags, much more document control, etc. (again, only if served as XML to supporting browsers).
-Future safe.
I still only serve it as text/html to all browsers. In reality it doesn't require any extra effort on your part (except the " />"), but pays off when you run into layout or other issues. If I write XHTML, I'm forced to write clean, valid code. When I used HTML, I found that if I made some mistake and overlooked it, it would bite me later down the road when starting to make changes.
........ HTML Advantages
-Slightly easier to write
-Very lenient on coding errors (HTML parser will correctly close unclosed tags, etc).
If you have Tidy plugged into FF, any errors are instantly apparent when checking on your local server, prior to uploading to the web server.
-Compatible with all browsers.
More specifically it's compatible with IE, which still has the lion's share of users, whether we like it or not.
XHTML Advantages
-Significantly more strict on coding errors (This is an advantage for some people like me, makes fixing problems much easier if code is valid).
Irrelevant if you are using something like Tidy, and corecting HTML errors as flagged up.
-Faster parse time (if served as XML to supporting browsers).
-It's XML. It means you can define custom tags, much more document control, etc. (again, only if served as XML to supporting browsers).
True - for supporting browsers. But for the majority who use IE, not true.
-Future safe.
You think HTML isn't as 'future safe'? HTML5 is on the horizon.
Frustrating though it is, without IE support, xhtml potential will not be realised on the web. As I read it, IE8 will probably not support xhtml. Maybe IE9 will. In the meantime, this advice remains sound, I think.
You think HTML isn't as 'future safe'? HTML5 is on the horizon.
Frustrating though it is, without IE support, xhtml potential will not be realised on the web. As I read it, IE8 will probably not support xhtml. Maybe IE9 will. In the meantime, this advice remains sound, I think.
And maybe IE12 will support HTML5. I can't really see any of the browsers rushing to support it as it is not being developed by the W3C to which all of the browser companies belong.
With the rate at which people are moving away from IE it will probably never get to a version 9 as there will not be enough people left using it by then to make it worthwhile for Microsoft to spend the time on it.
Thhe big advantage of XHTML over HTML even if you do serve it as HTML to all browsers is the W3C validator picks up more errors. As someone has already pointed out using Tidy negates this advantage. Of course it is difficult to use Tidy if your page contains textarea fields with JavaScript content for people to copy as Tidy can easily mangle the JavaScript into garbage if you don't have Tidy configured properly - it is often easier to just use the W3C validator with the page defined as XHTML.
I keep using XHTML !doctype, perhaps incorrectly sometimes as pointed out to me occasionally hereon. I have this notorious habit of writing self-closing tags "<img src="#" />" and "<br />", etc
I am working on a site that several pages still use a FLASH-based navigation, and one page has a CAPITAL letter starting the page's name. I cannot decompile the FLASH to correct this, and we aren't ready yet to fully abandon the FLASH navigation (but I built an HTML navigation that is visually nearly-as-good, -and it's editable and update-able). Because of the FLASH issue with CAP-letter, I have to use HTML strict !doctype, which is 'lenient' on use of CAPS. Otherwise, the FLASH navigation would send to visitor to a different page than the HTML navigation unless I maintained two identical pages with a slight variation of their names...
I did note that even though page validates HTML STRICT with TIDY, with the XHTML !doctype, it cites about two dozen 'warnings' missed otherwise. -I find this quite valuable.
And I *just know* that the W3C-Validator would cite even more warnings (mostly Accessibility issues, like possible foreground/background-color issues, etc).
I did note that even though page validates HTML STRICT with TIDY, with the XHTML !doctype, it cites about two dozen 'warnings' missed otherwise. -I find this quite valuable.
And maybe IE12 will support HTML5. I can't really see any of the browsers rushing to support it as it is not being developed by the W3C to which all of the browser companies belong.
I would rather go for XHTML for my website, coz it is an advanced HTML version and supports XML syntax. Even though HTML is enough to fulfill the purpose of your site now, who knows what development it requires in the long run.
Just need to keep in mind the followingh most Important Differences:
XHTML elements must be properly nested
XHTML elements must always be closed
XHTML elements must be in lowercase
XHTML documents must have one root element
Bookmarks