www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: HTML or XHTML DTD

  1. #1
    Join Date
    Aug 2007
    Location
    New Jersey, US
    Posts
    1,779

    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.

  2. #2
    Join Date
    Mar 2006
    Location
    Newcastle NSW Australia
    Posts
    4,033
    xhtml offers no advantage over html, and has to be incorrectly served as html for one particular browser. Have a read of this.

  3. #3
    Join Date
    Aug 2007
    Location
    New Jersey, US
    Posts
    1,779
    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

  4. #4
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    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.
    Last edited by TJ111; 09-20-2007 at 11:06 AM.

  5. #5
    Join Date
    Jun 2005
    Location
    United Kingdom
    Posts
    1,043
    Quote Originally Posted by TJ111
    ........
    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.

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Quote Originally Posted by TJ111
    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" your not even close to writing XHTML.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  7. #7
    Join Date
    Aug 2007
    Location
    New Jersey, US
    Posts
    1,779
    Seems to me like I'm better off with HTML, and I'm okay with that.

  8. #8
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    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.
    Stephen

  9. #9
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    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).
    Last edited by WebJoel; 09-20-2007 at 05:36 PM.
    I build for: Firefox and tweak for IE

  10. #10
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Quote Originally Posted by WebJoel
    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
    Fx add-on
    At least 98% of internet users' DNA is identical to that of chimpanzees

  11. #11
    Join Date
    Jun 2005
    Location
    United Kingdom
    Posts
    1,043
    Quote Originally Posted by felgall
    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 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?

  12. #12
    Join Date
    Apr 2007
    Posts
    33
    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

  13. #13
    Join Date
    Aug 2007
    Location
    New Jersey, US
    Posts
    1,779
    XHTML documents must have one root element
    What do you mean by that?

  14. #14
    Join Date
    Mar 2006
    Location
    Newcastle NSW Australia
    Posts
    4,033
    Quote Originally Posted by root123
    I would rather go for XHTML for my website, coz it is an advanced HTML version
    Huh? it offers no additional advances as yet
    and supports XML syntax
    XML 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
    ???

  15. #15
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    Quote Originally Posted by Centauri
    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).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles