Spacing
6.5
Lesson

Auto Margins

The margin property can be set to auto value. This horizontally centers an element.

The left and right margins are auto calculated by equally splitting the remaining space.

If margin-left is set to auto, the remaining space is assigned to left margin and hence the element aligns to the right.

If margin-right is set to auto, the element aligns to the left.