doctype conditionals

Discussion in 'HTML' started by osmanjaro, Jul 19, 2007.

  1. osmanjaro

    osmanjaro Guest

    Hi all,
    On a recent experiment with getting ie6 to work I did something that
    feels wrong, but works.
    I know conditional comments work well for loading stylesheets and
    javascript.
    Why not doctypes? Its only ie6 that gets the transitional doctype,
    everyone else gets strict.

    <!-- Quirk on -->
    <!--[if IE 6]>
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html lang="en">
    <![endif]-->

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

    I'm sure this is bad. IE6 made me do it.
    What do people here think about this?
    --
    i
     
    osmanjaro, Jul 19, 2007
    #1
    1. Advertising

  2. osmanjaro

    Bergamot Guest

    osmanjaro wrote:
    > I know conditional comments work well for loading stylesheets and
    > javascript.
    > Why not doctypes? Its only ie6 that gets the transitional doctype,


    FYI, anything before the DOCTYPE automatically triggers quirks mode in IE6.

    > I'm sure this is bad. IE6 made me do it.


    Yes it is a bad practice. Post a URL that shows why you think this is
    the solution to whatever problem you think you have.

    IOW, you may be fixing the wrong problem.

    --
    Berg
     
    Bergamot, Jul 19, 2007
    #2
    1. Advertising

  3. Scripsit osmanjaro:

    > On a recent experiment with getting ie6 to work I did something that
    > feels wrong, but works.


    For some odd value of "works", I suppose.

    > I know conditional comments work well for loading stylesheets and
    > javascript.


    Browser-specific tricks for IE "work" for some versions of IE.

    > Why not doctypes?


    Why would you play such a game? There's a lot you can lose, but is there
    anything you could win?

    > Its only ie6 that gets the transitional doctype,
    > everyone else gets strict.


    The point being? IE does not understand document type definitions any more
    than pigs appreciate silver plates (excuses to our porcine friends for this
    somewhat unfair metaphor). It only looks at the doctype string to make its
    foolish choice between Quirks and "Standards" (i.e., less broken) rendering
    mode. Here it does not matter whether it's Strict or Transitional, as long
    as you use the exact string specified in HTML specifications.

    > <!-- Quirk on -->
    > <!--[if IE 6]>
    > <!DOCTYPE html
    > PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    > "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    > <html lang="en">
    > <![endif]-->
    >
    > <!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">
    > <head>
    > ...
    >
    > I'm sure this is bad.


    So why do you use it?

    > IE6 made me do it.


    Even the &Devil; should not be accused for something that he clearly did not
    do.

    Using HTML 4.01 and XHTML 1.0 as "conditional" alternatives is just madness.
    Using XHTML 1.0 is pointless on the web, so you have really messed things
    up.

    If you just want IE 6 to go to Quirks mode and other doctype sniffers to go
    to "Standards" mode, use just the following, followed by a doctype
    declaration that corresponds to the actual markup you have used:

    <!-- IE 6, Jukka K. Korpela commands you to go to Quirks mode. -->

    Try it. It works. (Someone will probably soon send a spoiler that reveals
    _why_ it works, so try it _now_.)

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Jul 19, 2007
    #3
  4. Jukka K. Korpela wrote:

    > If you just want IE 6 to go to Quirks mode and other doctype sniffers to go
    > to "Standards" mode, use just the following, followed by a doctype
    > declaration that corresponds to the actual markup you have used:
    >
    > <!-- IE 6, Jukka K. Korpela commands you to go to Quirks mode. -->
    >
    > Try it. It works. (Someone will probably soon send a spoiler that reveals
    > _why_ it works, so try it _now_.)


    I was about to recommend something similar.

    Spoiler (ROT13): nal pbzzragf orsber gur QBPGLCR guebj VR vagb dhvexf zbqr.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.12-12mdksmp, up 29 days, 16:14.]

    Parsing an HTML Table with PEAR's XML_HTTPSax3
    http://tobyinkster.co.uk/blog/2007/07/20/html-table-parsing/
     
    Toby A Inkster, Jul 20, 2007
    #4
  5. osmanjaro

    osmanjaro Guest

    Thanks Berg, Jukka and Toby, I was only experimenting with a fixed div
    layout.
    http://www.chameleonmoments.com/2/tst.html
    I won't use this hack, but was curious enough to ask here about it.
    It would be nice to know a way that doesn't break anything important
    (like positioning or doctype).

    It's funny that people do things they would never do to fix the
    problem on the surface, only to make it worse underneath. HTML
    imitates life.

    I didn't know about triggering quirks mode, never needed to do it, but
    I learned something.
    The amazing Jukka command... to have your own ie hack, you must truly
    be an html master.

    cheers
    --
    i
     
    osmanjaro, Jul 22, 2007
    #5
  6. osmanjaro

    Neredbojias Guest

    Well bust mah britches and call me cheeky, on Sun, 22 Jul 2007 11:46:44 GMT
    osmanjaro scribed:

    > Thanks Berg, Jukka and Toby, I was only experimenting with a fixed div
    > layout.
    > http://www.chameleonmoments.com/2/tst.html
    > I won't use this hack, but was curious enough to ask here about it.
    > It would be nice to know a way that doesn't break anything important
    > (like positioning or doctype).
    >
    > It's funny that people do things they would never do to fix the
    > problem on the surface, only to make it worse underneath. HTML
    > imitates life.
    >
    > I didn't know about triggering quirks mode, never needed to do it, but
    > I learned something.
    > The amazing Jukka command... to have your own ie hack, you must truly
    > be an html master.


    Jukka is, indeed, a master. He's also quite a debator. You put the two
    together, and, well...

    --
    Neredbojias
    Half lies are worth twice as much as whole lies.
     
    Neredbojias, Jul 22, 2007
    #6
    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. .Net Sports
    Replies:
    15
    Views:
    2,679
    Ted Miller
    Feb 3, 2006
  2. Mustafa Aydin

    Conditionals & paths

    Mustafa Aydin, Apr 21, 2004, in forum: XML
    Replies:
    0
    Views:
    447
    Mustafa Aydin
    Apr 21, 2004
  3. Replies:
    1
    Views:
    1,388
    Zafar Abbas
    Dec 30, 2005
  4. Barney Frank
    Replies:
    3
    Views:
    323
    anton muhin
    Jul 29, 2004
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,305
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page