Click to See Complete Forum and Search --> : HTML or XHTML DTD


dtm32236
09-20-2007, 09:48 AM
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?

Thanks for any help.

Centauri
09-20-2007, 10:22 AM
xhtml offers no advantage over html, and has to be incorrectly served as html for one particular browser. Have a read of this (http://www.sitepoint.com/forums/showthread.php?t=393445).

dtm32236
09-20-2007, 10:35 AM
I decided to switch over to HTML Strict.... and it wasn't as much work as I thought it would be (thanks to Dreamweaver's File -> Convert feature).

Thank you Centauri and Dreamweaver ;)

TJ111
09-20-2007, 10:59 AM
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.

kiwibrit
09-20-2007, 11:29 AM
........
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 (http://www.w3.org/html/wg/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 (http://hixie.ch/advocacy/xhtml) remains sound, I think.

Fang
09-20-2007, 01:50 PM
I still only serve it (XHTML) as text/html to all browsers.
Then your writing bad HTML.
Until you've seen the "yellow screen of death (http://en.wikipedia.org/wiki/Yellow_Screen_of_Death)" your not even close to writing XHTML.

dtm32236
09-20-2007, 02:53 PM
Seems to me like I'm better off with HTML, and I'm okay with that.

felgall
09-20-2007, 04:45 PM
You think HTML isn't as 'future safe'? HTML5 (http://www.w3.org/html/wg/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 (http://hixie.ch/advocacy/xhtml) 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.

WebJoel
09-20-2007, 05:33 PM
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).

Fang
09-21-2007, 02:54 AM
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.
Try Total Validator (http://www.totalvalidator.com/index.html)
Fx add-on (https://addons.mozilla.org/en-US/firefox/addon/2318)

kiwibrit
09-21-2007, 03:56 AM
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.

However, the link I provided is a W3C page - and the dotnetslackers observation (http://dotnetslackers.com/XML/re-59770_WhatWG_W3C_and_HTML_5_0.aspx) is encouraging.

The good news is that the W3C has picked up the call, and the WhatWG and W3C working drafts of HTML 5 are now advancing in tandem.

Do you have definitive information that dotnetslackers is wrong?

root123
09-21-2007, 07:27 AM
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

dtm32236
09-21-2007, 08:15 AM
XHTML documents must have one root element

What do you mean by that?

Centauri
09-21-2007, 08:38 AM
I would rather go for XHTML for my website, coz it is an advanced HTML version Huh? it offers no additional advances as yetand supports XML syntaxXML is not a markup language.
XHTML elements must be properly nested So should html elements
XHTML elements must always be closed Non-content-holding html elements are implicitly closed by default - what's the advantage?
XHTML elements must be in lowercase Html code can be written lowercase as well - and looks more readable in my opinion.
XHTML documents must have one root element ???

TJ111
09-21-2007, 08:59 AM
XHTML documents must have one root element
???

I think what he means by this is elements such as <blockquote> must contain child tags, you can't just add text in there (which I always did).

Jeff Mott
09-21-2007, 11:47 AM
Quote: XHTML documents must have one root element

???The root element in HTML and XHTML documents is the HTML element (marked by the <html> tag). Of course XHTML and HTML both have only one root element, so there's certainly no advantage.

Fang
09-21-2007, 11:49 AM
Beware of XHTML (http://www.webdevout.net/articles/beware-of-xhtml)