PDA

View Full Version : Resolved Can't Center DIV in IE



talkinggoat
Jul 27th, 2010, 07:06 AM
Could someone please take a look at www.southlapatriots.info and tell me why the div, MainContent will not center in IE? I've been beating my head against it for hours, and can't figure out why. It works perfectly fine, in firefox. Suggestions, please.

Arbitrator
Jul 27th, 2010, 07:56 AM
Could someone please take a look at www.southlapatriots.info and tell me why the div, MainContent will not center in IE? I've been beating my head against it for hours, and can't figure out why. It works perfectly fine, in firefox. Suggestions, please.Internet Explorer improperly centers block-level elements (like div elements) via the text-align: center declaration instead of the margin-left: auto and margin-right: auto declaration pair when in quirks mode.

Looking at the table at http://hsivonen.iki.fi/doctype/, one can see that you're using a document type declaration that triggers quirks mode. Try another such as <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">. (Note that use of the HTML 4.01 Strict declaration is generally considered better practice, but it means stricter requirements compared to the one you're using. If you must use a (HTML 4.01) Transitional declaration, try <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">.)

talkinggoat
Jul 27th, 2010, 07:28 PM
Internet Explorer improperly centers block-level elements (like div elements) via the text-align: center declaration instead of the margin-left: auto and margin-right: auto declaration pair when in quirks mode.

Looking at the table at http://hsivonen.iki.fi/doctype/, one can see that you're using a document type declaration that triggers quirks mode. Try another such as <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">. (Note that use of the HTML 4.01 Strict declaration is generally considered better practice, but it means stricter requirements compared to the one you're using. If you must use a (HTML 4.01) Transitional declaration, try <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">.)

Using text-align: center worked, for now. That second pair of eyes really helps. Thanks for the input, Arbitrator.