SitePoint Sponsor

User Tag List

Page 1 of 4 1234 LastLast
Results 1 to 25 of 88

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XHTML1.0 vs XHTML 1.1

    Hi all,

    What's the difference between the above standards?

    Which should be used in webpages?

    Thanks.

    Kevin.

  2. #2
    SitePoint Guru momos's Avatar
    Join Date
    Apr 2004
    Location
    Belgium
    Posts
    919
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XHTML 1.0 is a reformulation of HTML 4.01 as an application of XML.
    XHTML 1.1 is a reformulation of XHTML 1.0 Strict using Modularization of XHTML.

    XHTML 1.0 is just an application of XML which uses the same set of element names and attributes (i.e., semantics) as HTML 4.01. It comes in three different DTDs (Strict, Transitional, Frameset) just like HTML 4.01.

    XHTML 1.1 uses a concept called Modularization of XHTML, which means that the definition is split into a number of modules, which you can combine in any combination. There's something called XHTML Basic, for instance, which comprises just the essential modules for simple documents. XHTML 1.1 uses all modules (including a module for Ruby annotations that isn't part of any XHTML 1.0 DTD).

    For most webpages, the logical choice is still HTML 4.01 Strict.

    Why HTML? Because a large majority of users still use Internet Explorer, which does not support XHTML at all. Although you may use XHTML markup and serve it as text/html so that IE will accept the document, it's pointless since you cannot use any advantage that XHTML may have over HTML.

    Why Strict? Because the Strict DTD enforces the separation of structure and presentation more than the Transitional DTD (which is mean to be used during a transitional phase when you convert old pre-HTML4 documents to a modern form).

    If you absolutely have to write a few scattered '/' characters in your markup to feel manly (or whatever), or if you belong to the .0001% of Web authors who really need XHTML and can afford to ignore IE users, you should probably stick to XHTML 1.0 Strict.

    If you serve the document as text/html, don't even think about using XHTML 1.1. It is not backwards-compatible with HTML and should not be served as text/html.
    Birnam wood is come to Dunsinane

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Sticking this thread so hopefully we don't have any more like it

  5. #5
    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)
    Off Topic:

    Well, you can hope but I am sure the question will still get asked several thousand times.

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by xhtmlcoder
    Off Topic:

    Well, you can hope but I am sure the question will still get asked several thousand times.
    just let me live in my fantasy world okay?

  7. #7
    Non-Member lostseed's Avatar
    Join Date
    Sep 2005
    Location
    Zurconion Soon!
    Posts
    1,549
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great thread, thanks for the post Autistic

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, if this thread is going to be sticky, I'll add another thing that seems to confuse many beginners.

    What is required for a document to be treated like XHTML?
    1. A content type that says it's an application of XML.
    2. An XML namespace equal to 'http://www.w3.org/1999/xhtml'.


    Content Type
    The content type (a.k.a. media type or MIME type) must be sent by the server in the Content-Type HTTP header. You cannot change the content type with a META element, since the user agent needs to know what the document is before starting to parse it. There are three MIME types that will do this for XHTML:
    • application/xhtml+xml
    • application/xml
    • text/xml

    Using text/xml is not recommended, because there are some serious encoding issues with that MIME type. The recommended one is application/xhtml+xml.

    Arguably, the server should not send any character encoding information in the Content-Type header, since X(HT)ML is meant to be a self-describing format where the encoding should be specified in the XML declaration. Thus the server should only send this:
    Code:
    Content-Type: application/xhtml+xml
    and the document should start with something like this:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    Note that if you use a MIME type of text/xml, the encoding will be US-ASCII unless the server sends encoding information in the Content-Type header. You cannot override it with an XML declaration (and, of course, not with a silly <meta/> element).

    XML Namespace
    The content type only tells the user agent that the document is an application of XML. Even if the MIME type is application/xhtml+xml, user agents don't know that it is, in fact, XHTML.

    The thing that tells them that is the 'xmlns' attribute of the document's root element:
    HTML Code:
    <html xmlns="http&#58;//www.w3.org/1999/xhtml" xml:lang="en">
    If you don't use this exact namespace URI, the document is not an XHTML document; it's general XML. That will cause some interesting effects in how the page is rendered... It will also cause certain elements to stop working, because the semantics is lost.

    What about DOCTYPE?
    Didn't I forget something in my list above? Surely, it's the doctype declaration that makes it XHTML? This techie stuff about HTTP headers and XML namespaces is just a smoke screen, isn't it? 'Fraid not.

    The doctype declaration doesn't matter at all, as far as browsers are concerned. Browsers that support XHTML will not do doctype switching when the document is served as an application of XML. At least not to my knowledge. They will use their strict rendering mode.

    The doctype is only used when you're validating your document. A validator must know with which flavour of XHTML you're claiming compliance. Browsers don't care.
    Birnam wood is come to Dunsinane

  9. #9
    Web Design Addict
    Join Date
    Mar 2004
    Posts
    2,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo
    and the document should start with something like this:
    Code:
    <?xml version="1.0" encoding="utf-8"?>

    So if my documents starts like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    Is there something wrong?
    Deron Sizemore
    ----------
    My Sites: LogoGala | Golf Ledger (coming soon)
    Twitter: Deron Sizemore

  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 deronsizemore
    So if my documents starts like this:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    Is there something wrong?
    No. The XML declaration is optional if you use utf-8 (or a subset of utf-8, such as us-ascii) or utf-16, or if you have specified the encoding with HTTP.
    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)
    The Doctype however matters with regard to referencing which syntax elements and attributes you are allowed to legally use within a strictly conforming XHTML document a Validating XML Parser may analyse it. A real XHTML UA does not necessary have to support client-side scripting either.

  12. #12
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xhtmlcoder
    The Doctype however matters with regard to referencing which syntax elements and attributes you are allowed to legally use within a strictly conforming XHTML document
    True, but an XML parser does not have to read the DTD or schema definition, and AFAIK none does.

    So you could use a 'target' attribute for a link even with a Strict doctype, and it would work in the browser even though it's not valid. The only validation errors that are caught are well-formedness errors, and those are caught with a vengeance!
    Birnam wood is come to Dunsinane

  13. #13
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great post Tommy and well stated !

    Nadia

  14. #14
    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)
    You are thinking browsers Tommy I meant Validating XML Processors and some check for Valid XHTML but as you say most browsers just use Well-formedness Parsers.

  15. #15
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    That's called fake xhtml. When using real xhtml you have to put the ?xml version="1.0" encoding="utf-8"?> at the top of your document as serve up the proper mime type as well. But you can't do that yet because IE doesn't support it.

  16. #16
    Web Design Addict
    Join Date
    Mar 2004
    Posts
    2,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I've got one that says it is "fake" and another says that there is nothing wrong....
    Who is right here?

    Stymiee: So if I use the proper xml declaration to serve the proper mime type at the top of the page IE users wont be able to view the page?
    Deron Sizemore
    ----------
    My Sites: LogoGala | Golf Ledger (coming soon)
    Twitter: Deron Sizemore

  17. #17
    Non-Member
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    4,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deronsizemore
    Okay, I've got one that says it is "fake" and another says that there is nothing wrong....
    Who is right here?

    Stymiee: So if I use the proper xml declaration to serve the proper mime type at the top of the page IE users wont be able to view the page?
    Hello

    the browser that is used most, 80%~85% ? is not playing ball

  18. #18
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deronsizemore
    Okay, I've got one that says it is "fake" and another says that there is nothing wrong....
    Who is right here?
    If you serve it as text/html then it's indeed "fake" XHTML; the browser will interpretet as if it was HTML. If you serve it as XML then it's "true" XHTML. You didn't say which it was, you only asked if there was anything wrong without the XML declaration.
    Simon Pieters

  19. #19
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deronsizemore
    Okay, I've got one that says it is "fake" and another says that there is nothing wrong....
    Who is right here?
    Simon is right, the XML declaration is optional under certain circumstances. The markup fragment you show seems correct, but we can't say whether it's 'right' or 'wrong' without knowing the MIME type. If it's application/xhtml+xml (or similar) it's 'right'. If it's text/html it's 'wrong' (i.e., not XHTML).

    Quote Originally Posted by deronsizemore
    So if I use the proper xml declaration to serve the proper mime type at the top of the page IE users wont be able to view the page?
    The XML declaration has nothing to do with that. It's the application/xhtml+xml MIME type that IE doesn't support.

    You may serve it as application/xml, which IE supports. It will then be treated as XML. However, IE does not understand the XHTML namespace, so it will not be treated as XHTML, but as generic XML.
    Birnam wood is come to Dunsinane

  20. #20
    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)
    In otherwords the User Agent or Server may under certain circumstances determine the outcome as to whether it ends up being processed as the genuine article.

  21. #21
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good,just want going to learn xml

  22. #22
    SitePoint Zealot
    Join Date
    Nov 2005
    Location
    Sweden
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a few references/tutorials that could be of interest:

    XHTML 1.1 Tutorial
    XHTML Basic 1.0 Tutorial
    XHTML Basic for mobile devices(what is XHTML Basic?)
    XHTML - A combination of HTML and XML

    Also, for those interested in using strict markup with XHTML in combination with Adsense, you should know there is a problem with Content-Type application/xhtml+xml.
    According to w3c XHTML should be sent as application/xhtml+xml. There is allowed, however, to use text/html on less strict modules such as XHTML Transitional.

    Since older browsers and IE doesn't understand application/xhtml+xml they can react by displaing the source code or not showing the document at all.

    Therefor, to use application/xhtml+xml it is best to let the server know if a client/browser requesting a page can handle application/xhtml+xml, and - if the browser doesn't handle it - send it as text/html.

    If PHP is used the following script can be used to send the different content types to different browsers:

    Code:
    <?php
    if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml") || 
    stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) {
        header("Content-Type: application/xhtml+xml; charset=iso-8859-1");
        header("Vary: Accept");
        echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
        }
    else {
        header("Content-Type: text/html; charset=iso-8859-1");
        header("Vary: Accept");
        }
    ?>
    If ASP and VBScript is used:

    Code:
    <%
    If InStr(Request.ServerVariables("HTTP_ACCEPT"), "application/xhtml+xml") > 0 
    Or InStr(Request.ServerVariables("HTTP_USER_AGENT"), "W3C_Validator") > 0 Then
        Response.ContentType = "application/xhtml+xml"
        Response.Write("<?xml version=""1.0"" encoding=""iso-8859-1""?>" & VBCrLf);
    Else
        Response.ContentType = "text/html"
    End If
    Response.Charset = "iso-8859-1"
    %>

  23. #23
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by carlsson
    According to w3c XHTML should be sent as application/xhtml+xml. There is allowed, however, to use text/html on less strict modules such as XHTML Transitional.
    XHTML 1.0 (regardless of whether it's Strict, Transitional or Frameset) may be served as text/html, provided that you follow all the guidelines in Appendix C of the XHTML 1.0 specification.

    If you do, the document is HTML to all intents and purposes. You cannot use any XML-features such as namespaces or CDATA-sections.

    Quote Originally Posted by carlsson
    If PHP is used the following script can be used to send the different content types to different browsers
    That's a very primitive content negotiation script, which doesn't take into accound things like quality values (Q values). For instance, your script would serve application/xhtml+xml to a user agent sending this Accept header:
    Code:
    Accept: text/html; application/xhtml+xml;q=0
    Not really a good move, eh?
    Birnam wood is come to Dunsinane

  24. #24
    SitePoint Zealot
    Join Date
    Nov 2005
    Location
    Sweden
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo
    XHTML 1.0 (regardless of whether it's Strict, Transitional or Frameset) may be served as text/html, provided that you follow all the guidelines in Appendix C of the XHTML 1.0 specification.

    If you do, the document is HTML to all intents and purposes. You cannot use any XML-features such as namespaces or CDATA-sections.
    Correct, I should have said XHTML 1.0 as a hole

    Quote Originally Posted by AutisticCuckoo
    That's a very primitive content negotiation script, which doesn't take into accound things like quality values (Q values). For instance, your script would serve application/xhtml+xml to a user agent sending this Accept header:
    Code:
    Accept: text/html; application/xhtml+xml;q=0
    Not really a good move, eh?
    Correct again, this is a more advanced one:


    Code:
    <?php
    $charset = "iso-8859-1";
    $mime = "text/html";
    function fix_code($buffer) {
    return (preg_replace("!\s*/>!", ">", $buffer));
    }
    if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
            if(preg_match("/application\/xhtml\+xml;q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
            	$xhtml_q = $matches[1];
                    if(preg_match("/text\/html;q=q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
                    	$html_q = $matches[1];
                            if((float)$xhtml_q >= (float)$html_q) {
                            $mime = "application/xhtml+xml";
    			}
                    }
            } else {
               	$mime = "application/xhtml+xml";
                    }
    }
    if($mime == "application/xhtml+xml") {
    	$prolog_type = "<?xml version=\"1.0\" encoding=\"$charset\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
    } else {
    	ob_start("fix_code");
            $prolog_type = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html lang=\"en\">\n";
    }
    header("Content-Type: $mime;charset=$charset");
    header("Vary: Accept");
    print $prolog_type;
    ?>

  25. #25
    Non-Member
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    4,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    html or the X part ?
    cool down


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
  •