CSS CSS Basics The Box Model Margins

Why does " margin: auto; " only make the left and right side equal, but not the top and bottom?

Why does " margin: auto; " only make the left and right side equal, but not the top and bottom?

Why does it give the same output as " margin: 0 auto; " why does it seem like it ignores the top and bottom when you give it a single value of auto. i thought single values should affect all 4 sides.

Thank you.

2 Answers

Philip Gales
Philip Gales
15,192 Points

It is a bit more complicated than I would care to explain. You can read about it here at StackOverflow though. This question is asked a lot.

Thanks i'll check it out.

Callum Anderson
Callum Anderson
8,837 Points

I wondered the same, and although I've just read the explanation given on the link posted by Philip - it still doesn't really explain why.

I guess it doesn't matter in the long run, I just wondered why.