SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 39
  1. #1
    SitePoint Zealot My220x's Avatar
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Clear up my HTML and XHTML questions please

    Hey,

    I have always written my site using XHTML 1.0 Strict as I thought it was the latest and greatest to use however I always served it as text/html and have found out that doing that the user agent uses a html parser instead of a xml parser thus meaning I will not be able to use any of the features XML bring to XHTML such as using other markup languages based on XML. So, as far as I am aware it's best to use HTML 4.01 strict as I am still following standards by writing valid HTML and seperating presentation from content using CSS and all modern browsers support it, however should I use XHTML if I will be writing all my HTML tags with opening and closing tags and not using attritbute minimization and such as at least if I decided one day to take advantage of the features XHTML brings I would be able to change my MIME type and be able to use them features without having to change my doctypes and such?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,217
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    yes

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot My220x's Avatar
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so I will be using XHTML but another question I have is why do people specify both the lang attribute and the xml:lang?

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An informal note from W3C says you 'may' serve a certain small subset of XHTML 1.0 as text/html – although you 'should' serve it as an application of XML. This subset is described in Appendix C of the XHTML 1.0 specification. Doing this means you're not really using XHTML at all, as far as browsers and other user agents are concerned; you're just using invalid HTML and relying on parser bugs.

    However, even Appendix C compatible XHTML markup that is served as text/html must still be proper XHTML. In other words, it must still work if served as an application of XML. Serving it as HTML is tacitly understood to be a temporary measure (otherwise there's absolutely no point in using XHTML markup).

    The dual use of the lang and xml:lang attributes is necessary in this case. The xml:lang attribute is the recommended way for XML documents. It's invalid HTML and won't be understood by HTML parsers, which is why you need to double up with the lang attribute.

    The best way to avoid any trouble is, of course, to forget the XHTML myth and just use honest HTML 4.01 (Strict, of course). That's the latest standard with any widespread support. Besides, XML is not intended for marking up web pages in the first place, and is a poor choice for the job unless it's 100% machine generated. The draconian error handling required by XML makes hand-coding a really bad idea.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Zealot My220x's Avatar
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    An informal note from W3C says you 'may' serve a certain small subset of XHTML 1.0 as text/html although you 'should' serve it as an application of XML. This subset is described in Appendix C of the XHTML 1.0 specification. Doing this means you're not really using XHTML at all, as far as browsers and other user agents are concerned; you're just using invalid HTML and relying on parser bugs.

    However, even Appendix C compatible XHTML markup that is served as text/html must still be proper XHTML. In other words, it must still work if served as an application of XML. Serving it as HTML is tacitly understood to be a temporary measure (otherwise there's absolutely no point in using XHTML markup).

    The dual use of the lang and xml:lang attributes is necessary in this case. The xml:lang attribute is the recommended way for XML documents. It's invalid HTML and won't be understood by HTML parsers, which is why you need to double up with the lang attribute.

    The best way to avoid any trouble is, of course, to forget the XHTML myth and just use honest HTML 4.01 (Strict, of course). That's the latest standard with any widespread support. Besides, XML is not intended for marking up web pages in the first place, and is a poor choice for the job unless it's 100% machine generated. The draconian error handling required by XML makes hand-coding a really bad idea.
    Thanks for the reply, I have now decided to use HTML 4.01 strict seeing as I will not benefit from XHTML theres no point in me using it.

  6. #6
    Non-Member
    Join Date
    Oct 2008
    Location
    Banned
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try reading this article that explains when to use HTML and when to use an XHTML.

    Article

  7. #7
    SitePoint Zealot My220x's Avatar
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I have read that before, again it basically goes down to their being no point of using XHTML as I don't need the advantages it brings.

  8. #8
    Non-Member
    Join Date
    Oct 2008
    Location
    Banned
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have coded in html and xhtml and to be honest I have no idea why someone would recommend xhtml over html.

  9. #9
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,217
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    for me, it is more important to conform to strict

    i started on html (netscape gold, those were the days... but i digress)

    i went to xhtml but then changed back

    i still close all my tags, though (like any good obsessive compulsive coder, eh )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  10. #10
    Non-Member
    Join Date
    Oct 2008
    Location
    Banned
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I would still code in lowercase and closing tags if i went back to html 4.01 strict. I may try html 5 from validator.w3.org and see whats that about

  11. #11
    SitePoint Zealot My220x's Avatar
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    for me, it is more important to conform to strict

    i started on html (netscape gold, those were the days... but i digress)

    i went to xhtml but then changed back

    i still close all my tags, though (like any good obsessive compulsive coder, eh )
    Yeah even though I am now coding in HTML 4.01 Strict I am still closing all my tags as I am use to it.

  12. #12
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XHTML has been a problem for the W3C and Web page authors from its inception. MSIE Browsers do not support XHTML served as Content (MIME) Type application/xhtml+xml which is the way it should be served IAW the W3C specification. Other standards compliant Browsers -- FireFox, Opera, Safari, Mozilla, et al. do support that Content Type thus providing XML functionality. The W3C long ago added Appendix C to the XHTML 1.0 Specification that provides for serving XHTML as Content (MIME) Type text/html -- which is really just HTML using XHTML syntax.

    Microsoft does not recognize XHTML documents served as content (MIME) type application/xhtml+xml and until they do just about all XHTML will be served as HTML (content type text/html) as a matter of practicality.

    There is one great advantage in using XHTML (even when served as text/html) versus HTML -- the well-formedness constraints make for better structured Markup for those who do not normally employ that principle when composing HTML pages. However, there is no advantage in using valid XHTML 1.0 served as text/html versus well structured, well formed and valid HTML 4.01.

    Of course, a strict Doctype/DTD should always be used as that insures correct rendering in future Browser updates (avoiding deprecated elements and attributes).

    Note that the Content-Type declaration in meta tags is just informational -- it doesn't have any influence on how the page is actually served.

    JFP

  13. #13
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jamesicus View Post
    XHTML has been a problem for the W3C and Web page authors from its inception. MSIE Browsers do not support XHTML served as Content (MIME) Type application/xhtml+xml which is the way it should be served IAW the W3C specification. Other standards compliant Browsers -- FireFox, Opera, Safari, Mozilla, et al. do support that Content Type thus providing XML functionality. The W3C long ago added Appendix C to the XHTML 1.0 Specification that provides for serving XHTML as Content (MIME) Type text/html -- which is really just HTML using XHTML syntax.

    Microsoft does not recognize XHTML documents served as content (MIME) type application/xhtml+xml and until they do just about all XHTML will be served as HTML (content type text/html) as a matter of practicality.

    There is one great advantage in using XHTML (even when served as text/html) versus HTML -- the well-formedness constraints make for better structured Markup for those who do not normally employ that principle when composing HTML pages. However, there is no advantage in using valid XHTML 1.0 served as text/html versus well structured, well formed and valid HTML 4.01.

    Of course, a strict Doctype/DTD should always be used as that insures correct rendering in future Browser updates (avoiding deprecated elements and attributes).

    Note that the Content-Type declaration in meta tags is just informational -- it doesn't have any influence on how the page is actually served.

    JFP
    Great, you finally made the switch from DP to Sitepoint? Welcome.
    Cross browser css bugs

    Dan Schulz you will be missed

  14. #14
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    Great, you finally made the switch from DP to Sitepoint? Welcome.
    Thank you, SoulScratch.

    JFP

  15. #15
    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 jamesicus View Post
    MSIE Browsers do not support XHTML served as Content (MIME) Type application/xhtml+xml
    Internet Explorer doesn't support XHTML at all.
    If you serve it as application/xhtml+xml, IE will prompt for download.
    If you serve it as application/xml or text/xml, IE will parse and treat it as XML, but not as XHTML.

    Of course you can serve it as text/html and make it work in IE (provided you stick to the limited subset of XHTML markup outlined in Appendix C), but then you're not using XHTML at all.
    Birnam wood is come to Dunsinane

  16. #16
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Internet Explorer doesn't support XHTML at all.
    If you serve it as application/xhtml+xml, IE will prompt for download.
    If you serve it as application/xml or text/xml, IE will parse and treat it as XML, but not as XHTML ..........
    Indeed. Putting it another way, MSIE Browsers will not retrieve and render XHTML served as content (MIME) type application/xhtml+xml correctly. MSIE 6.0 release 2900 and 7.0 will display such pages alright but will not render xml content. MSIE 6.0 release 2800 and earlier Browsers present a download screen -- selecting OPEN displays a plain, text only page (sans style sheet) and again will not render xml.

    JFP

  17. #17
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the much referenced Microsoft stance on IE XHTML rendering: Microsoft MSIE 7.0 Blog

    JFP

  18. #18
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,788
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Interesting that he says

    I made the decision to not try to support the MIME type in IE7 simply because I personally want XHTML to be successful in the long run.
    when the effect is the exact opposite. Unless of course he means that he expects that by not supporting it IE will die and then it will take off because of being fully supported by all the modern browsers.
    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="^$">

  19. #19
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    .......... The best way to avoid any trouble is, of course, to forget the XHTML myth and just use honest HTML 4.01 (Strict, of course). That's the latest standard with any widespread support ..........
    Yes, I use HTML 4.01 (strict) for the great majority of my web page composition. Of course, the advent of the W3C Semantic Web necessitates the use of XHTML (RDF/XML, XHTML+RDFa, FOAF, et al.) but then it is still best to serve it as text/html (or at least via content negotiation).

    JFP

  20. #20
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Interesting that he says



    when the effect is the exact opposite. Unless of course he means that he expects that by not supporting it IE will die and then it will take off because of being fully supported by all the modern browsers.
    I really do not fully understand the rationale of MS.

    JFP
    Last edited by jamesicus; Jan 5, 2009 at 19:58. Reason: rewite of text

  21. #21
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, here is an XHTML 1.0 (strict) page served "pure" as content (MIME) type application/xhtml+xml.

    W3C (SGML) Markup Validation and XML Schema Validation results are included.

    JFP
    Last edited by jamesicus; Jan 5, 2009 at 18:28. Reason: added validation info

  22. #22
    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 jamesicus View Post
    Of course, the advent of the W3C Semantic Web necessitates the use of XHTML (RDF/XML, XHTML+RDFa, FOAF, et al.) but then it is still best to serve it as text/html (or at least via content negotiation).
    Sorry, but if it's possible to serve it as text/html there is no way that it necessitates the use of XHTML. Anything served as text/html IS HTML as far as the user agent is concerned. That means only HTML stuff will work (with the exception of XML NET syntax for certain element types, but that's due to parser bugs).

    Anything that requires XML features is impossible to serve as text/html.
    Birnam wood is come to Dunsinane

  23. #23
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Sorry, but if it's possible to serve it as text/html there is no way that it necessitates the use of XHTML. Anything served as text/html IS HTML as far as the user agent is concerned. That means only HTML stuff will work (with the exception of XML NET syntax for certain element types, but that's due to parser bugs).

    Anything that requires XML features is impossible to serve as text/html.
    Yes, that was poor wording on my part (necessitate)-- I should have cited the following W3C references:

    http://www.w3.org/TR/xhtml-rdfa-primer/
    http://www.w3.org/TR/rdfa-syntax/

    There is some interesting commentary relating to HTML/XHTML in these references/specifications.

    As a point of interest, the W3C serves their XHTML+Rdfa Semantic Web Activity page as text/html.

    JFP

  24. #24
    Non-Member
    Join Date
    Oct 2008
    Location
    Banned
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great, you finally made the switch from DP to Sitepoint? Welcome.
    What is DP?

  25. #25
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    DigitalPoint.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work


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
  •