Which DTD Should I Use?

Discussion in 'HTML' started by Gene Wirchenko, Dec 20, 2011.

  1. Dear HTMLers:

    I have been ignoring the issue of DTDs and just using the default
    that Dreamweaver 8 offers. This is XHTML 1.0 Transitional. This has
    worked fine.

    It does not work with <style>-defined CSS. (I use IE9 under
    Windows 7.) I changed to HTML 4.01 Strict, and then the CSS worked.

    In case it matters, my pages will have JavaScript in them.

    Which DTD should I be using? And why? Good-quality links are
    very welcome.

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, Dec 20, 2011
    #1
    1. Advertising

  2. Gene Wirchenko <> wrote

    > Dear HTMLers:
    >
    > I have been ignoring the issue of DTDs and just using the default
    > that Dreamweaver 8 offers. This is XHTML 1.0 Transitional. This has
    > worked fine.


    Not really, it's all tag soup.

    To be valid XHTML, all elements must be closed, including those that self
    close, such as IMG, so it becomes <img />. To be valid HTML, those self
    closing elements MUST NOT be closed, it MUST be <img> to be valid.

    If you don't serve XHTML the way it should be served as
    application/xhtml+xml, then you are serving it as text/html. IE cannot
    render XHTML - it has to be served HTML. So when it gets <img /> served
    as text/html, it's really just getting invalid markup that it's
    correcting. But, since it is receiving tag soup, there is no guarantee
    that it will be rendered the way it should be.



    >
    > It does not work with <style>-defined CSS. (I use IE9 under
    > Windows 7.) I changed to HTML 4.01 Strict, and then the CSS worked.


    See above.

    >
    > In case it matters, my pages will have JavaScript in them.


    You should not have any problems if you are using HTML, with XHTML,
    script and CSS must use CDATA, or use an external script (recommended).
    >
    > Which DTD should I be using? And why?


    Your best bet is to use HTML 4.01 Strict, an external stylesheet, and
    external JavaScript. Don't use XHTML unless you have a VERY good reason
    to.

    The strict doctype should be used for new documents. The transitional is
    for documents that are in, well, transition. Transitional allows elements
    and attributes that have been deprecated in favor of CSS. Why? Because
    it's a lot easier to change one file that says "body {background-color:
    #fff; color:#000;}" than it is to go into all the files and change <body
    bgcolor="#FFFFFF" color="#000000"> if you want to go from a white
    background to a pale yellow background.


    > Good-quality links are very welcome.


    Google is your friend.


    --
    Adrienne Boswell
    Arbpen Web Site Design Services - http://www.cavalcade-of-coding.info/
    The Good Plate - Fresh Gourmet Recipes - http://the-good-plate.com/
    Please respond to the group so others can share
    Adrienne Boswell, Dec 20, 2011
    #2
    1. Advertising

  3. On Tue, 20 Dec 2011 21:43:29 +0000 (UTC), Adrienne Boswell
    <> wrote:

    >Gene Wirchenko <> wrote


    [snip]

    >> Which DTD should I be using? And why?

    >
    >Your best bet is to use HTML 4.01 Strict, an external stylesheet, and
    >external JavaScript. Don't use XHTML unless you have a VERY good reason
    >to.


    Got it.

    [snip]

    >> Good-quality links are very welcome.

    >
    >Google is your friend.


    Not always. When I do not know enough to evaluate the results,
    the results are not too useful. A bit of orientation helps. Thank
    you for the orientation that you provided.

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, Dec 20, 2011
    #3
  4. Gene Wirchenko

    dorayme Guest

    In article <>,
    Gene Wirchenko <> wrote:

    >
    > Which DTD should I be using? And why? Good-quality links are
    > very welcome.


    In your case and for many others and for now:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    One reason is that it is well established, validators know about
    it and if you want to play safe with browsers you can do worse.
    Using the modern but still raw <!DOCTYPE html> may be for some
    but if your software is not the very latest and your grasp of the
    complexities is not firm, stick with the above for the moment.

    --
    dorayme
    dorayme, Dec 20, 2011
    #4
  5. On Tue, 20 Dec 2011 12:25:42 -0800, Gene Wirchenko wrote:

    > Dear HTMLers:
    >
    > I have been ignoring the issue of DTDs and just using the default
    > that Dreamweaver 8 offers. This is XHTML 1.0 Transitional. This has
    > worked fine.
    >
    > It does not work with <style>-defined CSS. (I use IE9 under
    > Windows 7.) I changed to HTML 4.01 Strict, and then the CSS worked.
    >
    > In case it matters, my pages will have JavaScript in them.
    >
    > Which DTD should I be using? And why? Good-quality links are
    > very welcome.


    This is my perspective, and should be read as "as I understand it" and
    "in my opinion". Other people might well disagree with parts or the whole.

    Historically, html was based on sgml. Html 4 was pretty much defined by
    the turn of the century. Xml was see as "the next great thing" and there
    was a movement to remake html in the form of xml.

    (depending who you ask, xml was or was not a development of html in the
    first place)

    XHTML 1.0 was basically a re-write of html 4.01 to match the rules of xml.
    It didn't add anything new to html 4.01, other than making it legal xml.

    The theory was that by making a few minimal changes, existing html 4.01
    could be ported to the new shiny xml based xhtml.

    Of course, that never happened, there was too much html 4.01 (and older
    markup) in existence, and no-one was going to rework all their existing
    markup when the browsers still supported the old style (sound familiar?).

    xhtml 1.1 was a "ground up" rewrite of html as xml. It suffered some
    pretty fundamental problems, not least of which was that different
    browsers (msie was generally the odd-one-out) needed it served as
    different mime types to understand it properly.

    Eventually, xhtml suffered stagnation and became a dead end. At the same
    time, html 5 was becoming the next thing.

    The current situation is:

    html 4.01 - mature, well documented, predictable behaviour across all
    browsers as long as markup is compliant

    xhtml 1.0 - stepping stone intended for rewriting html 4.01 to comply
    with xml document structures, not intended for writing new pages in, but
    also mature, well documented, with fairly predictable behaviour[1] across
    all browsers as long as markup is compliant.

    xhtml 1.1 - xml based document markup, seems to be an evolutionary dead
    end in the development of www markup languages, but also mature, well
    documented, with fairly predictable behaviour[1] across all browsers as
    long as markup is compliant.

    html 5 - a working draft, subject to change,

    I still prefer to work in html 4.01, basically because compliant 4.01
    markup still has the best chance of appearing as intended across the
    widest selection of browsers currently in use.

    Rgds

    Denis McMahon

    [1] possibly including in some cases "doesn't render at all because the
    served mime type wasn't recognised"
    Denis McMahon, Dec 21, 2011
    #5
  6. 2011-12-21 19:59, Denis McMahon wrote:

    > On Tue, 20 Dec 2011 12:25:42 -0800, Gene Wirchenko wrote:
    >
    >> Dear HTMLers:
    >>
    >> I have been ignoring the issue of DTDs and just using the default
    >> that Dreamweaver 8 offers. This is XHTML 1.0 Transitional. This has
    >> worked fine.
    >>
    >> It does not work with <style>-defined CSS. (I use IE9 under
    >> Windows 7.) I changed to HTML 4.01 Strict, and then the CSS worked.
    >>
    >> In case it matters, my pages will have JavaScript in them.
    >>
    >> Which DTD should I be using? And why? Good-quality links are
    >> very welcome.

    >
    > This is my perspective, and should be read as "as I understand it" and
    > "in my opinion". Other people might well disagree with parts or the whole.


    Undoubtedly, like anything posted to Usenet. I have refrained from
    answering the question, as I don't know the specifics of Dreamweaver,
    and I don't know whether the OP is developing brand new pages or
    maintaining/developing old pages. It makes the huge difference.

    In any case, the question "which DTD should I be using?" is as such
    rather vague. The doctype declaration has two functions: browser mode
    selection, and validation. If you don't validate your pages, then the
    short answer is: don't use any doctype declaration, if you want "quirks
    mode"; and use <!doctype html>, if you want "standards mode". And if you
    use validation, you should understand the doctype issue on your own;
    otherwise the validator reports will just confuse you.

    The question "which version of HTML should I be using" is something
    completely different. But it is important to realize that browser don't
    care about HTML versions. Well, they might care about HTML vs. XHTML
    _if_ you serve XHTML as genuine XHTML in the HTTP headers, but nobody
    should do that without understanding the consequences, and few people do
    it anyway.

    It really doesn't matter much which "version of HTML" you use. What
    matters is what tags and attributes you use, and how. This is tagsoup
    world. Even if your doctype declares your document as HTML 2.0, browsers
    will happily implement your use of tags introduced in HTML5 drafts if
    they support them at all. And even if you declare HTML5, which declares
    many old tags as obsolete, cursed, anathema, and criminal (pardon my
    slight exaggeration), browsers will still obey your pre- HTML 2.0 markup
    as usual, to the extent that they know about it at all.

    > Historically, html was based on sgml.


    No, it was just nominally retrofitted to SGML.

    > Html 4 was pretty much defined by
    > the turn of the century.


    In 1997; later slightly edited in 1998 and 1999.

    > (depending who you ask, xml was or was not a development of html in the
    > first place)


    XML is a simplification of SGML; seeing it as a development of HTML is a
    gross category error.

    > XHTML 1.0 was basically a re-write of html 4.01 to match the rules of xml.


    Yes.

    > It didn't add anything new to html 4.01, other than making it legal xml.


    It did. The differences were never properly documented. Nobody was
    interested enough.

    > The theory was that by making a few minimal changes, existing html 4.01
    > could be ported to the new shiny xml based xhtml.


    Hardly. The idea of XHTML is that XHTML documents can be processed by
    generic XML tools and combined with other XML documents. Using XHTML
    just as a publishing format for web pages is absurd: it gains nothing.

    > xhtml 1.1


    is best mercifully forgotten.

    > Eventually, xhtml suffered stagnation and became a dead end. At the same
    > time, html 5 was becoming the next thing.


    HTML5 has HTML serialization and XHTML serialization. So instead of
    killing XHTML, it makes it an option.

    > html 4.01 - mature, well documented, predictable behaviour across all
    > browsers as long as markup is compliant


    Well, nothing like that, except as compared with the alternatives. :)

    > I still prefer to work in html 4.01, basically because compliant 4.01
    > markup still has the best chance of appearing as intended across the
    > widest selection of browsers currently in use.


    There's no magic in sticking to HTML 4.01. Most constructs there are
    widely supported, though often with considerable rendering and
    functional differences. But just being part of HTML 4.01 guarantees
    nothing; browser developers have no interest in HTML 4.01 any more. And
    some HTML5 features work fine in browsers, because they are not really
    new, just standardization of common practice.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Dec 21, 2011
    #6
  7. On Tue, 20 Dec 2011 12:25:42 -0800, Gene Wirchenko <>
    wrote:

    >Dear HTMLers:
    >
    > I have been ignoring the issue of DTDs and just using the default
    >that Dreamweaver 8 offers. This is XHTML 1.0 Transitional. This has
    >worked fine.
    >
    > It does not work with <style>-defined CSS. (I use IE9 under
    >Windows 7.) I changed to HTML 4.01 Strict, and then the CSS worked.
    >
    > In case it matters, my pages will have JavaScript in them.
    >
    > Which DTD should I be using? And why? Good-quality links are
    >very welcome.


    Thank you very much for your answers. This is the sort of thing
    that is difficult to find on the Web. (Well, I suppose I could find
    it, in amongst all of the junk.)

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, Dec 21, 2011
    #7
  8. Gene Wirchenko

    cwdjrxyz Guest

    On Dec 21, 1:27 pm, Gene Wirchenko <> wrote:
    > On Tue, 20 Dec 2011 12:25:42 -0800, Gene Wirchenko <>
    > wrote:
    >
    > >Dear HTMLers:

    >
    > >     I have been ignoring the issue of DTDs and just using the default
    > >that Dreamweaver 8 offers.  This is XHTML 1.0 Transitional.  This has
    > >worked fine.

    >
    > >     It does not work with <style>-defined CSS.  (I use IE9 under
    > >Windows 7.)  I changed to HTML 4.01 Strict, and then the CSS worked.

    >
    > >     In case it matters, my pages will have JavaScript in them.

    >
    > >     Which DTD should I be using?  And why?  Good-quality links are
    > >very welcome.


    First, unless you serve even a perfect xhtml of any type as
    something.html, on most servers your xhtml page is served only as
    ordinary html. To properly serve xhtml, something such as .xhtml can
    be used and the mime type proper for .xhtml must be set on the server.
    Or you can do something a bit more complicated using header exchange.
    Most of my pages are written and served as xhtml 1.1 which is really
    little more difficult than using html 4.01 strict after you learn to
    do it. Mis-serving a xhtml page as html usually works unless the page
    has some xml content. Thus I would not change all of my older pages
    that work.

    If you use Javascript, you can throw many validation errors, on a
    xhtml page unless you are very careful. The reason is that Javascript
    includes many things that are not legal in xml and a xhtml page is
    parsed as xml when properly served. If the xhtml page contains no xml
    and is mis-served as html, this may not matter. However sometimes you
    can get so many validation errors that sorting through all of them can
    be quite a chore. There are open and close xml constructs that you can
    put around the JavaScript that instruct not to parse the Javascript as
    xhtml, which it is not. Often using an external script will solve the
    problem. Also using document.write is not allowed. Again this may not
    matter if your xhtml page uses no xml and is mis-served as html. The
    way I usually get around this is to use server side php rather than
    client side JavaScript. You likely could use Microsoft server side
    snake script (ASP) if it suits you better than php. The rules for
    writing a xhtml page have to be a bit more complicated than those for
    a html page, because the page must work if it contains only html, only
    xml, or a mixture of both. Xml is much more strict than html, and an
    error such as not closing something may cause the page not to view at
    all on some or all browsers.

    I think html5, for the most part, is a step backward. However it can
    be served as xhtml5, which is what I do on a few experimental xhtml5
    pages. Also you can write your main page in some version of html or
    xhtml that meets most of your needs. You can then embed another page
    or pages in it of any Doctype using the proper objects. This has not
    been done much because IE browsers do not understand these objects.
    However there are ActiveX objects that IE does understand. You have to
    then use Microsoft conditional comments to route to the ActiveX object
    and route to ordinary objects for other browsers. Thus you can have a
    xhtml 1.1 page that embeds an html 4.01 transitional page, that
    perhaps contains a Java applet. Of course the embedded pages need to
    validate in their declared Doctype which may be just about any legal
    one that works for the embedded page. You can even embed another page
    in an embedded page.
    cwdjrxyz, Dec 23, 2011
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joseph Tilian
    Replies:
    0
    Views:
    337
    Joseph Tilian
    Dec 21, 2004
  2. Ronald Fischer
    Replies:
    4
    Views:
    1,741
    Ronald Fischer
    Mar 17, 2005
  3. test
    Replies:
    2
    Views:
    1,984
    Oliver Wong
    Jul 28, 2006
  4. Mithil
    Replies:
    8
    Views:
    413
    Mithil
    Aug 6, 2007
  5. admyc
    Replies:
    3
    Views:
    390
    Martin Honnen
    Dec 3, 2007
Loading...

Share This Page