Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOmar Suriel
5,403 PointsWhy 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
15,193 PointsIt 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.
Callum Anderson
8,837 PointsI 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.
Omar Suriel
5,403 PointsOmar Suriel
5,403 PointsThanks i'll check it out.