SitePoint Sponsor

User Tag List

Page 1 of 9 12345 ... LastLast
Results 1 to 25 of 215
  1. #1
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Use XHTML or HTML 4.01 Doctype?

    I recently read an interesting post online (can't find the link), but it was about whether using XHTML, especially as a doctype, is really necessary if you don't plan on using any of the extra's that come with having an xhtml doctype, especially when IE has trouble being served that type of doctype (I might need some clarifying on this).

    Basically, keep your markup clean, close your tags, keep them lowercased, but is having the XHTML doctype necessary? Do you need an XHTML Transitional docytpe in order to have XML files on your site?

    With that being said, lets say I was to use an HTML 4.01 doctype. Can I still close certain links like this

    <tag /> ???

    Thanks
    Bryan

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The doctype declaration only matters when it comes to validation. The thing that controls whether or not you can use XML features is the media type (a.k.a. content type or MIME type), which has to be sent as an HTTP header. You cannot set it with a <meta&#160;http-equiv="..."> element.

    There are very few sites that need XHTML today. Look at this ongoing discussion for more info: Why XHTML?
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bam, that was the link Tommy. Thanks

  4. #4
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is typically what I use, so am I good?

    <!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">

    I guess I don't have a MIME type.

  5. #5
    SitePoint Zealot spinball's Avatar
    Join Date
    Oct 2004
    Location
    Harrison Twp., MI
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why wouldn't you hold yourself up to the highest standards? I prefer to code and validate to the strictest standards available. Using a HTML DTD will allow you to be sloppy, even if unintentional.

  6. #6
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jag5311
    This is typically what I use, so am I good?

    <!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">

    I guess I don't have a MIME type.
    Yeah that should like somewhat like this (from my site):
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
    It is always good to include the language your page is in to make sure it is rendered correctly.

    As for the mime type, you can do this:
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    Joe

  7. #7
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BluDragon
    As for the mime type, you can do this:
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    Quote Originally Posted by AutisticCuckoo
    The thing that controls whether or not you can use XML features is the media type (a.k.a. content type or MIME type), which has to be sent as an HTTP header. You cannot set it with a <meta http-equiv="..."> element.
    .

  8. #8
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by spinball
    Why wouldn't you hold yourself up to the highest standards? I prefer to code and validate to the strictest standards available. Using a HTML DTD will allow you to be sloppy, even if unintentional.
    No, not paying attention will make you sloppy. The DOCTYPE has little to do with how clean your code is. I've seen some very nice HTML 4.01 and some very nasty XHTML.

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jag5311
    This is typically what I use, so am I good?
    I would strongly urge you to switch over to using a Strict DTD. Whether you use HTML 4.01 Strict or XHTML 1.0 Strict is not as important (although there are quite a few things you should be aware of if you're using a XHTML doctype).

    Quote Originally Posted by jag5311
    I guess I don't have a MIME type.
    This is sent by your web server and typically defaults to text/html. XHTML 1.0 may be served as text/html under certain circumstances (the infamous Appendix C), but it should be served as application/xhtml+xml. If it isn't, it's not treated as XHTML, but as HTML with syntax errors.

    The only way you can affect the MIME type (apart from changing the web server settings) is via a server-side scripting language. For instance, in PHP you can do this:
    PHP Code:
    header('Content-Type: application/xhtml+xml; charset=utf-8'); 
    Birnam wood is come to Dunsinane

  10. #10
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so are you saying uses this

    Code:
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "DTD/xhtml1-strict.dtd">

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should use an absolute URI for the DTD:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    Birnam wood is come to Dunsinane

  12. #12
    SitePoint Zealot
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's also very important for the rendering of your page. All xhtml doctypes put the browsers in "standards mode" (good). I think html 4.01 strict also does that but not html 4.01 transitional. So if you can live up to the strict part I you might as well use the html doctype (4.01 strict), if you prefer the syntax.
    Good web hosting info All you need to know about web hosting
    xhbml(web dev blog)
    CSS Viking CSS blog

  13. #13
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    These trigger Almost Standards Mode in Gecko:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd">
    These trigger Full Standards Mode in Gecko:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    This one will trigger Quirks mode:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    If you serve your XHTML with an XML MIME type there is no DOCTYPE switching at all. All XML files are rendered in Full Standards Mode regardless of the DOCTYPE (if any).
    Simon Pieters

  14. #14
    SitePoint Addict Jack Matier's Avatar
    Join Date
    Feb 2005
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I keep on seeing XHTML 1.0 Strict, Transitional etc..

    Is XHTML 1.1 in beta or something and I haven't realized this? Because as far as i know there is only XHTML 1.1 doctype.

    I guess I use XHTML because I think it can fall back on HTML when it wants to, but it can't do the same the other way around? I should really research this before statin eh?

  15. #15
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use XHTML 1.1 you MUST serve it as XML.
    Simon Pieters

  16. #16
    SitePoint Enthusiast MstrBob's Avatar
    Join Date
    Dec 2004
    Location
    New York City
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jack Matier
    Okay, I keep on seeing XHTML 1.0 Strict, Transitional etc..

    Is XHTML 1.1 in beta or something and I haven't realized this? Because as far as i know there is only XHTML 1.1 doctype.

    I guess I use XHTML because I think it can fall back on HTML when it wants to, but it can't do the same the other way around? I should really research this before statin eh?
    XHTML 1.1 is XHTML, only modularized. It is similar to Strict in it's syntax, but the biggest difference is that the DTD is broken up into different modules. It is in a way, a step towards XHTML 2. Modularized DTD and it Should Not have a text/html MIME-type. It Should have an application/xhtml+xml MIME type, or may have an application/xml or text/xml MIME type. See:

    http://www.w3.org/TR/xhtml-media-types/

  17. #17
    SitePoint Addict Jack Matier's Avatar
    Join Date
    Feb 2005
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks guys.. I'll do that next chance I get.

  18. #18
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jack Matier
    Is XHTML 1.1 in beta or something and I haven't realized this? Because as far as i know there is only XHTML 1.1 doctype.
    Just as XHTML 1.0 is a reformulation of HTML as an application of XML, XHTML 1.1 is a reformulation of XHTML 1.0 Strict using Modularization of XHTML. Clear, huh?

    Transitional doctypes were meant to be used on old-skool documents during a transitional period, to make it possible to validate them as HTML4. The transitional period was supposed to last until you had removed all the presentational stuff from the HTML and put it into the CSS where it belongs, i.e. until you could validate the page with a Strict DTD.

    Some think that Transitional means that it's OK to use them even for new documents until some unspecified event occurs, but I personally believe that is wrong.

    W3C strongly recommends Strict DTDs for new documents. Why they decided to incorporate a Transitional DTD and a Frameset DTD with XHTML 1.0 is beyond me. They realised their mistake, though, so for XHTML 1.1 there is only one DTD, and it's strict.
    Birnam wood is come to Dunsinane

  19. #19
    SitePoint Addict Jack Matier's Avatar
    Join Date
    Feb 2005
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    reads all that a few times

    So, basically they made XHTML 1.0 so you can do things like Strict and Transitional still and not develop what? webmaster cubicle shock? then they moved to XHTML 1.1 which has a modularized DTD so they can later move to XHTML 2.0.

    YAY!! I think I got it

  20. #20
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They made XHTML 1.0 to make a standard for XML compliant HTML.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  21. #21
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz
    They made XHTML 1.0 to make a standard for XML compliant HTML.
    I think 'HTML-compliant XML' would be more correct, actually.

    The whole point of XHTML is that it is XML, so that you can use a lightweight XML parser instead of a complex SGML parser. And other XML tools, of course.

    By using the same element types and attributes as in HTML, it allows user agents to understand the semantics without a lot of change.

    XHTML is not HTML that looks like XML; it's XML that looks like HTML. A lot of people don't seem to realise that, or to grasp the significance of the difference between those two statements. (And that's why there are so many badly written pages with an XHTML doctype declaration in them.)
    Birnam wood is come to Dunsinane

  22. #22
    SitePoint Addict Jack Matier's Avatar
    Join Date
    Feb 2005
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    (And that's why there are so many badly written pages with an XHTML doctype declaration in them.)
    Well, okay. I dont' want to fall into that pitiful trap (which I seem to be already).. Now, what is a bad example, and what is a good example?

    I'm sitting here with books I got from the library.. I'll look at them tomorrow. Maybe it'll be my XML day of fun.

  23. #23
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spinball
    Why wouldn't you hold yourself up to the highest standards? I prefer to code and validate to the strictest standards available. Using a HTML DTD will allow you to be sloppy, even if unintentional.
    That is false and misleading.

    To produce a valid HTML file is very hard, for non-trivial documents. That is, it is hard to produce a large, complex valid HTML document.

    Apart from being based on SGML, which is much more complex than XML, HTML is basically the same as XHTML 1.0. It has virtually the same elements, entities and attributes. Producing a valid HTML document from scratch will be exactly as complex as producing a valid XHTML document from scratch, providing it is well-formed.

    Most documents which claim to be HTML 4.01 valid (or even HTML 3.2 valid) are not.

    Most documents which claim to be XHTML 1.0 valid are not.

    There is a common misconception that HTML allows for sloppy code whereas XHTML does not. I believe this misconception was formed because people are less likely to validate an HTML document than they are an XHTML document. People believe, for some reason, that it is "ok" to code in HTML that is invalid. HTML does NOT allow sloppy code. Only "tag soup", which is not HTML and not XHTML, allows for sloppy code.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  24. #24
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Valid HTML 4 here ! what is the difference really ? any advantages of XHTML ?
    I use HTML4 & CSS for my pages would it be better to use XHTML/CSS ?
    hello

  25. #25
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Convincing people to go to the trouble of validating their (X)HTML documents is difficult.

    How is SGML more complicated than XML, other than the case insensitivity and the optional end tags of SGML?

    Quote Originally Posted by AutisticCuckoo
    XHTML is not HTML that looks like XML; it's XML that looks like HTML. A lot of people don't seem to realise that, or to grasp the significance of the difference between those two statements.
    The difference isn't very clear to me, would you care to explain or give us a link to an explanation?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


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
  •