[thelist] Second stupid CSS question of the evening

Brian Cummiskey Brian at hondaswap.com
Tue Oct 26 22:14:25 CDT 2004

M. Seyon wrote:

> Message from Christian (10/26/2004 10:13 PM)
>> Dear list,
>> So...how does one "center" an entire page in CSS?  I have already 
>> used absolute positioning for certain DIVs - didn't really think it 
>> through, perhaps - am I going to have to totally redo things?
> Theoretically you use margin: auto but IE doesn't support this.
> Read here - http://css-discuss.incutio.com/?page=CenteringBlockElement 
> - for more info and a workaround.

I use a work-around like this:

	text-align: center; /* centers board in MSIE */

	margin: 2em auto 2em auto; /* centers the box, applies a 2em gap all around.  adjust to fit your needs  */
	text-align: left; /* re-aligns the text to left, to negate the centering above */	
	width: 98%; /* or whatever you want here.  don't use 100% though, because it will cause some horizontal scroll bars in most browsers.  leave width: out all together if you just want to control it via margin width.

More information about the thelist mailing list