doctype conditionals

O

osmanjaro

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?
 
B

Bergamot

osmanjaro said:
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.
 
J

Jukka K. Korpela

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_.)
 
T

Toby A Inkster

Jukka said:
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/
 
O

osmanjaro

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
 
N

Neredbojias

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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,097
Latest member
RayE496148

Latest Threads

Top