Forum Moderators: not2easy

Message Too Old, No Replies

Div not centering

         

andrewsmd

10:04 pm on Oct 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a container div that holds all of my other content (divs, text, images etc). My problem is, it won't center in IE 8. Any idea why? Here is the code for the div
#container{
margin-left: auto;
margin-right: auto;
width: 800px;
}
Then in my html it's something like
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles/internalStyles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
</div>
<div id="headerRight">
</div>
<div id="leftColumn">
</div>...
</div>
</body>
</html>

caribguy

10:49 pm on Oct 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Centered with respect to... the body element?

body {
width:100%;
}

swa66

10:50 pm on Oct 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE8 does support standard centering.

Try adding a full doctype to start.
Does the document validate (both html and CSS) ?

andrewsmd

3:00 pm on Oct 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It was the doctype problem. I have read about different doctypes and what not, but I still don't truly understand what they do? Can someone explain it for me or point me to a good link that does? Thanks,

swa66

11:23 pm on Oct 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Browsers -for historic reasons- use 3 modes to render a document in:
- Quirks Mode
- Standards Mode
- Almost Standards Mode

You do _not_ want Quirks mode in a modern document.

Standards mode is the outright standard.
Almost standards mode is the halfway thing.

Both are usually workable although I like standards mode better (less guessing what the browsers will do).

Which of the modes they use depends on the doctype.

A list of doctypes you can use is at:
[w3.org...]

If you need to support IE6, don't use the xml preample (or anything else in front of your doctype) as it throws IE6 in quirks mode.

IE8 has a 4th mode: IE7 mode: emulating the bugs of IE7. I don't get why anybody wants that, but people do for some reason that's beyond me.

An overview of which doctype causes what mode in which rendering engine is at [hsivonen.iki.fi...] (scroll down for the table)

And then there is the HTML5 doctype: <!DOCTYPE html>
It should trigger standards mode, but I've not yet played with it myself.

andrewsmd

4:00 pm on Nov 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have had to use the IE7 mode for the google maps api. IE 8 doesn't like it for some reason, and it was the only way to fix it. I doubt anyone "wants" to reproduce the errors in IE 7, it's just that IE 8 has its own set of crap that just doesn't work like it does on every other browser :). Thanks for the help.

rocknbil

4:32 pm on Nov 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can someone explain it for me or point me to a good link that does?

Choosing the best doctype for your site [webmasterworld.com]
Why of us should NOT use XHTML [webmasterworld.com]