SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Member
    Join Date
    Apr 2013
    Location
    Bangladesh
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why i should use HTML Over XHTML?

    Can you explain when i should use XHTML over HTML?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,295
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    It's fine to use either, in most cases. It's rare that anyone uses true XHTML anyway, because it doesn't work in IE8 and under. For most websites, you have to serve your content as text/html, meaning that the doctype is irrelevant. XHTML has stricter rules, but that doesn't mean you can't follow those rules anyway.

  3. #3
    SitePoint Member
    Join Date
    Apr 2013
    Location
    Bangladesh
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your responce.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,295
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    [QUOTE=a1technology;5386719]HTML's syntax is more concise than XHTML's[/qote]

    Really? It would be good to back that up with some reasoning.

    Quote Originally Posted by a1technology
    I wonder why you loking to use XHTML, You should use HTML5.
    Quote Originally Posted by a1technology
    I would recommend XHTML 1.0. It'll give some level of future-proofing.
    Quote Originally Posted by a1technology
    HTML5 will soon completely displace XHTML as the dominant markup language for webpages.
    Quote Originally Posted by a1technology
    XHTML won’t be going anyway anytime soon though.
    Some of your statements seem contradictory.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,861
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by a1technology View Post
    I wonder why you loking to use XHTML, You should use HTML5. HTML5 will soon completely displace XHTML as the dominant markup language for webpages.
    I don't see how XHTML 5 is going to be displaced when it is being developed in parallel with HTML 5. Whatever you can do with HTML 5 can also be done with XHTML 5 (since IE8 doesn't really support either).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,311
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)
    Just my personal prediction, but for the foreseeable future, I don't think the XHTML mime type is going to become at all popular.
    "First make it work. Then make it better."

  7. #7
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mhhh... i always thought xHTML couldn't be descripted as a product, it's just a way of using HTML in the correct way and in a structured way. Why wouldn't xHTML work in Explorer 8? it works fine here...

  8. #8
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    MSIE 8.0 doesn't support the recommended X(HT)ML MIME 'application/xhtml+xml' media type [RFC3236], which is the primary media type for XHTML Family documents. Thus IE 8.0 doesn't understand XHTML and just treats the markup grammar as if it were HTML not XHTML under 'text/html'. If the author served the XHTML as 'application/xhtml+xml' IE 8.0 would ask you to download the file, it wouldn't display... Furthermore XHTML is an application of XML thus requires well-formedness or will use draconian error handling via a XML Processor and halt on none well-formed markup errors.

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,295
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by kleurplaten88 View Post
    Why wouldn't xHTML work in Explorer 8? it works fine here...
    It only works if servered up as text/html, which means it's not actually XHTML anyway. If you serve it up as application/xhtml+xml. it won't work in IE8 and under. It was still recommended because the XHTML rules encouraged more tidy coding.

    A real XHTML document would start with something like this:


    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr"> 
    <head> 
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    More details here: http://www.sitepoint.com/forums/show...0-vs-XHTML-1-1
    and here: http://www.sitepoint.com/forums/show...ML-vs-HTML-FAQ

  10. #10
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    A real XHTML document would start with something like this:


    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr"> 
    <head> 
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    No, it shouldn't.
    Simon Pieters

  11. #11
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Ralph, it probably should be more like the following if using XHTML 1.0 Strict:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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">
    You cannot really set the MIME type with META when sending to a XML Parser. Think back to the 'purposely malformed' code demo samples I wrote: Spot the Error 3: Calling all Sleuths! and the comments I made in the Judge Feedback.


Tags for this Thread

Bookmarks

Posting Permissions

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