tags:

views:

55

answers:

2

Hello,

I want to center a div container on a page, in the css I am using

margin-left:auto;

does not seem to work.

Anything goes here

Thanks

+2  A: 

This should work:

margin:0px auto;

Or you can even try this if you want:

margin:auto;
position:relative;
width: 600px; /* or whatever width */
Sarfraz
Thanks............
Jean
@Jean: You are welcome :)
Sarfraz
+2  A: 

You can center a div horizontally with:

margin: 0 auto;

There's no need for the addition of "px" when you set it to 0.
But: this doesn't work unless you set a width for the div.

So the complete CSS for this would be for example:

width: 500px; 
margin: 0 auto;

This creates a 500px width div, centered horizontally in it's container.

MysticEarth
because of lame IE, you have to add px.
Sarfraz
for older browsers i mean
Sarfraz