/    Sign up×
Community /Pin to ProfileBookmark

HTML or XHTML DTD

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.

to post a comment
HTML

16 Comments(s)

Copy linkTweet thisAlerts:
@CentauriSep 20.2007 — xhtml offers no advantage over html, and has to be incorrectly served as html for one particular browser. Have a read of this.
Copy linkTweet thisAlerts:
@dtm32236authorSep 20.2007 — 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 ?
Copy linkTweet thisAlerts:
@TJ111Sep 20.2007 — 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.

[b]HTML Advantages[/b]

-Slightly easier to write

-Very lenient on coding errors (HTML parser will correctly close unclosed tags, etc).

-Compatible with all browsers.

[b]XHTML Advantages[/b]

-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.
Copy linkTweet thisAlerts:
@kiwibritSep 20.2007 — ........

[b]HTML Advantages[/b]

-Slightly easier to write

-Very lenient on coding errors (HTML parser will correctly close unclosed tags, etc).[/quote]


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.[/quote] More specifically it's compatible with IE, which still has the lion's share of users, whether we like it or not.

[b]XHTML Advantages[/b]

-Significantly more strict on coding errors (This is an advantage for some people like me, makes fixing problems much easier if code is valid).[/quote]

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).
[/quote]


True - for supporting browsers. But for the majority who use IE, not true.
-Future safe.[/quote]

You think HTML isn't as 'future safe'? [url=http://www.w3.org/html/wg/html5/]HTML5[/url] 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, [url=http://hixie.ch/advocacy/xhtml]this advice[/url] remains sound, I think.
Copy linkTweet thisAlerts:
@FangSep 20.2007 — I still only serve it (XHTML) as text/html to all browsers.[/QUOTE]
Then your writing bad HTML.

Until you've seen the "yellow screen of death" your not even close to writing XHTML.
Copy linkTweet thisAlerts:
@dtm32236authorSep 20.2007 — Seems to me like I'm better off with HTML, and I'm okay with that.
Copy linkTweet thisAlerts:
@felgallSep 20.2007 — You think HTML isn't as 'future safe'? [url=http://www.w3.org/html/wg/html5/]HTML5[/url] 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, [url=http://hixie.ch/advocacy/xhtml]this advice[/url] remains sound, I think.[/QUOTE]


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.
Copy linkTweet thisAlerts:
@WebJoelSep 20.2007 — 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="#" [B]/[/B]>" and "<br [B]/[/B]>", 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 [I]two identical pages[/I] 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 [I]even more[/I] warnings (mostly Accessibility issues, like possible foreground/background-color issues, etc).
Copy linkTweet thisAlerts:
@FangSep 21.2007 —  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.[/QUOTE]
Try Total Validator

Fx add-on
Copy linkTweet thisAlerts:
@kiwibritSep 21.2007 — 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.[/QUOTE]

However, the link I provided is a W3C page - and the [url=http://dotnetslackers.com/XML/re-59770_WhatWG_W3C_and_HTML_5_0.aspx]dotnetslackers observation[/url] 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.[/quote]

Do you have definitive information that dotnetslackers is wrong?
Copy linkTweet thisAlerts:
@root123Sep 21.2007 — 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
Copy linkTweet thisAlerts:
@dtm32236authorSep 21.2007 — XHTML documents must have one root element[/QUOTE]

What do you mean by that?
Copy linkTweet thisAlerts:
@CentauriSep 21.2007 — I would rather go for XHTML for my website, coz it is an advanced HTML version[/QUOTE] Huh? it offers no additional advances as yetand supports XML syntax[/QUOTE]XML is not a markup language.
XHTML elements must be properly nested[/QUOTE] So should html elements
XHTML elements must always be closed[/QUOTE] Non-content-holding html elements are implicitly closed by default - what's the advantage?
XHTML elements must be in lowercase[/QUOTE] Html code can be written lowercase as well - and looks more readable in my opinion.
XHTML documents must have one root element[/QUOTE] ???
Copy linkTweet thisAlerts:
@TJ111Sep 21.2007 — 

XHTML documents must have one root element[/quote]

???[/QUOTE]


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).
Copy linkTweet thisAlerts:
@Jeff_MottSep 21.2007 — Quote: XHTML documents must have one root element

???[/quote]
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.
×

Success!

Help @dtm32236 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...