tags:

views:

155

answers:

3

I am usually using this code

div#wrapper{width:900px; margin: 0 auto;}

div#header{float:left; width: 900px;}

div#sidebar{float:left; width: 300px;}

div#content{float:left; width:600px;}

div#footer{float:left; width: 900px; clear:both;}

and I have this markup

<div id="wrapper">
 <div id="header"></div>
 <div id="sidebar"></div>
 <div id="content"></div>
 <div id="footer"></div>
</div>

somehow the layout breaks in IE6: the whole layout floats to the left!

any knowhows on this one?

EDIT: layout is valid; centering works in IE7 and 8 (but breaks in quirks)

EDIT here's how it looks in quirks mode alt text

A: 

Try this styling instead, there's no reason to float anything but the side-bar, just adds more complexity to confuse IE6.

div#wrapper{width:900px; margin: 0 auto;}
div#header{width: 900px;}
div#sidebar{float:left; width: 300px;}
div#content{margin-left: 300px; width:600px;}
div#footer{width: 900px; clear:both;}
Nick Craver
+1  A: 

You need to have a doctype declared..

any doctype will do ..

(checked)

Gaby
oh, I forgot to notify that the page is valid, doctype declared and all..the code given is on the layout only
Ygam
@Ygam - the doctype needs to be on the very first line, before anything else, otherwise it'll trigger quirks mode
K Prime
@Ygam, it works great on my system in IE 6 when i add a doctype at the top.. the moment i remove it, it gets the behaviour you mention .. Perhaps if you can provide a live example ..
Gaby
http://www.thehotelinventory.com/test - here you go, a bit of markup difference but structurally, it is the same
Ygam
@Ygam, the url you provided works fine in IE6 and IE7 ..
Gaby
@Ygam, if you have to support quirks mode, then add `body {text-align:center;}`.. although it would be wiser to find a solution so that you do not go in quirks mode ...
Gaby
hm...that's bad...cuz it breaks in quirks mode; a colleague told me that quirks mode is like running it in IE6
Ygam
@Ygam, IE6 can work in standard-compliant mode.. look at http://msdn.microsoft.com/en-us/library/bb250395%28VS.85%29.aspx
Gaby
great tip. thanks! btw, what to you use to test your site in IE6? and test it also in later versions?
Ygam
@Ygam, i just have multiple computers :)
Gaby
A: 

Like Gaby says, a doctype will do the trick. Give this a try at the top of your document:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
ScottE