Looking at the MDN article for CSS margin it says:
margin
When two values are specified, the first margin applies to the top and bottom, the second to the left and right.
Citation: developer.mozilla.org/en-US/docs/W...
So margin: 0 auto is the same as the following 4 properties:
margin: 0 auto
margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto;
When margin-left and margin-right are both auto that will usually center-align a Block Level Element, like a <div>.
margin-left
margin-right
auto
<div>
Thanks!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Looking at the MDN article for CSS
margin
it says:Citation: developer.mozilla.org/en-US/docs/W...
So
margin: 0 auto
is the same as the following 4 properties:When
margin-left
andmargin-right
are bothauto
that will usually center-align a Block Level Element, like a<div>
.Thanks!