Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > doctype conditionals

Reply
Thread Tools

doctype conditionals

 
 
osmanjaro
Guest
Posts: n/a
 
      07-19-2007
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

 
Reply With Quote
 
 
 
 
Bergamot
Guest
Posts: n/a
 
      07-19-2007
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
 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      07-19-2007
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/

 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      07-20-2007
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/0...table-parsing/
 
Reply With Quote
 
osmanjaro
Guest
Posts: n/a
 
      07-22-2007
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





 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      07-22-2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With Valid DOCTYPE. Larry Lindstrom HTML 19 06-12-2012 02:07 PM
C# to VB.net conversion for "?" conditionals .Net Sports ASP .Net 15 02-03-2006 04:11 PM
XSD: ways to deal with conditionals on attribute value? Piper707@hotmail.com XML 1 12-30-2005 09:10 PM
Newbie question about formatting long conditionals Barney Frank Python 3 07-29-2004 10:04 AM
Conditionals & paths Mustafa Aydin XML 0 04-21-2004 05:25 PM



Advertisments