fordie’s blog

02 Aug, 2006

Sometimes the little thing you forget causes you the most pain

Posted by: Mark In: aide-mémoire| box model| browsers| css| web development| web standards| xhtml

I spend a lot of time wrestling with CSS working round IE’s broken box model.

A lot of this pain could have been avoided, if only I’d remembered about the “doctype switch”.

If you don’t know what a box model is, or why IE’s is broken, have a look at this.

There are lot’s of CSS hacks that help you get around this issue, but by far the most effective solution is to put IE into “Standards Mode”, this is done using a doctype declaration. As the name sort of implies, this is a line of code that declares the type of document you are serving to your client.
I knew that I could use a doctype to change IE’s rendering mode (because gnarly reminded me the other day), but I couldn’t remember which one to use. There are lot’s of articles on the web about this, but none that I saw simply said “if you want standards mode - do this”.

So here it is…

Thanks to Hurricane on the DDN Forum

If you want to put IE into standards compliant mode

Use:

A full strict doctype, either HTML 4.01 strict or XHTML 1.0 strict without an XML prologue.

In other words:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

needs to be the first thing in your xhtml document

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
  • Technorati

2 Responses to "Sometimes the little thing you forget causes you the most pain"

1 | hurricane

August 4th, 2006 at 8:04 pm

Avatar

HTML 4.01 rather than HTL ;)

Also, some people will know the XML prologue as the more correct XML declaration :)

2 | Mark

August 5th, 2006 at 9:00 pm

Avatar

Thanks Hurri, I fixed the post :o)

Comment Form

Flickr PhotoStream

    witch oneWitches of West Worthingbecause the internets need more kitteh picturesInteresting pub vending machine

fordie, elsewhere:

if you're an internet stalker these would be good sites for you to stalk me on…


Latest Tweet