Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

margin: auto auto [duplicate]

Tags:

css

centering

Possible Duplicate:
Why don't margin-top: auto and margin-bottom:auto work the same as their left and right counterparts?
What is the rationale behind margin-top: auto and margin-bottom: auto amounting to 0 margin?

Why doesn't margin: auto auto; add vertical centering? Shouldn't the auto keyword tell the browser to split the margins equally between the top and bottom? I was under the impression that was what it does for left and right margins.

like image 469
Usman Mutawakil Avatar asked Nov 14 '25 13:11

Usman Mutawakil


1 Answers

Ultimately it's a w3c spec -

If 'margin-top', or 'margin-bottom' are 'auto', their used value is 0.

It does seem like it would be handy.

like image 178
Fluidbyte Avatar answered Nov 17 '25 08:11

Fluidbyte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!