View Full Version : Very basic problem with centering

05-12-2009, 04:52 PM
This is so basic but it is eluding me:

the css

* {

body{width:903px; text-align:center; background-color:#c4c6ba}

the html


<table cellpadding="0" cellspacing="0" border="0" width="903">
<tr><td colspan="3">
<img src="images/Header.png" alt="banner"
ALT="banner" BORDER="0" USEMAP="#map1" height="157" width="903 ">
<td align="left"><img src="images/leftside.png" alt="spacer" width="6" height="432"></td>
<td align="center"> FLASH GOES HERE </td>
<td align="right"><img src="images/rightside.png" alt="spacer" width="9" height="432"></td>
<tr><td colspan="3"><img src="images/bottomshadow.png" alt="spacer"></td>

<map name="map1" id="map1">
<area shape="rect" coords="760,75,900,110" alt="register" href="<?php echo site_url('register'); ?>" >


It just stays on the left.
I simply want the whole body to be in the middle.
I have done this hundreds of times but this time I don't see it!!
Help please!

05-12-2009, 05:07 PM

margin: 0 auto;

05-13-2009, 03:53 AM
Why you use tables instead of div tag?

here is some code for positioning the div element into the center of page:

<div id="global_div" style="width:500px; height:200px; margin-left:auto; margin-right:auto;">
here you can put another div left or right or up and down and so on...

This is just and idea...

05-13-2009, 04:54 AM
Hello beedie,
to center an element you need three things:

a DocType
an element with a width
that elements right and left margins set to auto

05-13-2009, 05:19 AM
check out Excavator's Sig.

There is a bunch of info in them :thumbsup: