Tell us what’s happening:
I figured out the answer but I’m just wondering why I need to set margin-top to 0, margin-left and margin-right to auto when the question is asking this, " Set the width of the section elements to 80% of their parent container. Then, use margins to center the section elements, adding 10px to the bottom margin.
Also, ensure the section elements cannot be larger than 600px in width."
Okay I kind of get it… I know that if margin-left and right are set to auto it will center them, but what about margin-top? Why does it set to 0 when the question didn’t ask about margin-top? Does it have something to do with the bottom margin?
Sorry maybe I should have made it clearer. The hint tells me to set margin-top to 0 but I don’t understand why is that necessary for centering the section elements with margins. I expected to set the margin-top to auto in order to center the elements.
Setting the top margin to 0 is not necessary to center an element horizontally. The auto value will not work for vertical centering. You have to use some other technique like flexbox.
I don’t see in the instructions where it is asking you to set the top margin to 0, but I do see that the hint is telling you to. The instructions should probably tell you to set the top margin to 0. But it is not necessary in order to center the element horizontally.