Skip to content
WJunction - Webmaster Forum

How do i align my webpage to the center?

Status
Not open for further replies.
Hi,

I'm working on a new site and I want to center align the whole page.

I use margin:0 auto; in my css file and it works with firefox and chrome, but in IE9 the whole page is aligned to the left.

Thanks for any help.
 

6 comments

Don't use the above. It's not good practice. Use margin auto so it's something like the following in your CSS
PHP:
.something {margin:0 auto;display:block;}

And your html would be like this:
PHP:
<div class="something">Text goes here</div>
 
Probably because you have not set a DOCTYPE, IE is rendering the page in Quirks Mode and not recognizing "margin: 0 auto".
Add this at the beginning of your html document ;) "<!DOCTYPE html>".
 
Hi,

I'm working on a new site and I want to center align the whole page.

I use margin:0 auto; in my css file and it works with firefox and chrome, but in IE9 the whole page is aligned to the left.

Thanks for any help.

Do you have comments above the doctype? If you do, pages break completely in IE.

If you don't have a doctype, you need one. use xhtml 1.0 strict or html5 doctype.

More on doctype over here:
http://www.alistapart.com/articles/doctype/
 
Status
Not open for further replies.

About the author

D
Active Member · Joined
51
Messages
1
Reactions
8
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom