Center align a div in IE 8

Usually when I want to center align a div on a page, I use margin:auto auto and set my width to a specific width, like 940px in my stylesheet. But, this does NOT work in IE 8. So to make that work, use

width:940px
height:100%
position:absolute
left:50% (to tell that your div should start in the middle of the page)
margin-left:-490px (half of your div size)

Thanks to this site

0
0
votes
Rate this article!
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

4 Comments
newest
oldest most voted
Inline Feedbacks
View all comments
Anonymous

You need to add a vaild doctype for IE to centrally align a div using margin auto.

Anonymous

use this instead:

css-margin:auto;
html-

Anonymous

use this instead:

css-margin:auto;
html-
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot; >

Lise

Thanks for sharing 🙂
/Lise