Page 1 of 1

Center a DIV

Posted: Sat Jun 17, 2006 3:13 pm
by phppage
Would anyone know how I could horizontally center a DIV section in the middle of a page. The DIV needs to be fixed at 800 pixels wide but of course the page width may vary from different resolution settings on the users machine.

Posted: Sat Jun 17, 2006 3:26 pm
by Oren
Set the left and right margins to 'auto'.

Posted: Sat Jun 17, 2006 3:36 pm
by phppage
Oren wrote:Set the left and right margins to 'auto'.
Thanks for your quick reply. Tried that but found that it doesn't work in IE. Found the solution.

http://www.andybudd.com/archives/2004/0 ... /index.php

Posted: Sat Jun 17, 2006 3:46 pm
by Oren
Yeah, that's exactly what I meant. I just forget to mention to tell you to put in the body text-align: center; :P Sorry about that.
This is exactly the way I always use.