Skip to content Skip to sidebar Skip to footer

Margin: 0 Auto Not Working In Ie Only

I am trying to center a div #logo_alt containing an image using margin: 40px auto 0px auto;. Problem:: On Chrome, it looks perfect, but in IE, this img-containing div is aligned to

Solution 1:

The HTML file start off with <html xmlns="http://www.w3.org/1999/xhtml">.

Well there's your problem. You need to give your document an XHTML doctype declaration since your root element has that xmlns attribute anyway. Then IE will work in standards mode and render your margin: 0 auto style correctly.

Solution 2:

Firstly, add a doctype to prevent IE from slipping into quirks more.

Then try this...

body {
    width: 100%;
}

Post a Comment for "Margin: 0 Auto Not Working In Ie Only"