What does the CSS styling "margin : 0 auto" do to my section element?

.container {
    border: 1px solid black;
    margin: 0 auto;
}

What does the CSS styling “margin : 0 auto”, do to my section element? Is there a difference if I just put 0 with no auto ? Isnt the default just 0, and why should I put AUTO after i give the value 0?

1 Like

Hey @Tomaage, hope you are well.

You can check this video again which explain it in detail:
https://academy.moralis.io/lessons/box-model

Also you have this website which explain the use or margin:
https://www.w3schools.com/css/css_margin.asp

Carlos Z

1 Like

@Tomaage

Hey bro:

margin: 0; - all margins 0
margin: 0 10; - top and bottom margins 0, left and right margins 10
margin: 3 10 auto; top margin 3, right and left margins 10, bottom auto
margin: 1 2 3 4; top 1, right 2, bottom 3, left 4

Hope that helps - sorry if it’s a bit cryptic…