tags:

views:

37

answers:

2
div
{
margin:90px auto;
}

This code centers the div in chrome with a top margin of 90px, but the results are different in all other browsers ..

is there a common method to center the div and have a top margin at the same time ?

A: 

I assume you want the text content of the div to be aligned centred if so use.

div
{
  margin:90px auto;
  text-align:centre;
}
Salil
i just want to center the div ..
Sakti
It'd be 'center', anyways, not 'centre'. Just the messenger. :p
reisio
+1  A: 
div {
    margin: 90px auto;
    width: 900px;
    height: 100px;
}

This works for me in Firefox. I get a 900px by 100px box centered with a 90px top and bottom margin.

N. Lucas
Its not working for me ..What ver of firefox do you have ?
Sakti
It works for me in FF 3.6.3
animuson
I'm also using 3.6.3
N. Lucas
Also works for me in IE 8.0.7600.16835 and Chrome 5.0.375.70
animuson
it worked.. actually i tagged the div inside a section tag.. which seems to be supported only by chrome..
Sakti