doctype conditionals

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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
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"
    " ">
<html lang="en">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      " ">

<html xmlns=" ">

I'm sure this is bad. IE6 made me do it.
What do people here think about this?

Re: doctype conditionals

osmanjaro wrote:
Quoted text here. Click to load it

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

Quoted text here. Click to load 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.


Re: doctype conditionals

Scripsit osmanjaro:

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

So why do you use it?

Quoted text here. Click to load it

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

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

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

Re: doctype conditionals

Jukka K. Korpela wrote:

Quoted text here. Click to load it

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 /

Re: doctype conditionals

Thanks Berg, Jukka and Toby, I was only experimenting with a fixed div
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.


Re: doctype conditionals

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

Quoted text here. Click to load it

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

Half lies are worth twice as much as whole lies.

Site Timeline