Horizontally centring an element


  • padding: 0
    margin: 0
    box-sizing: border-box

width: 1100px
margin: auto
background-color: red


You can set the margin property to auto to horizontally centre

the element within its container.

The element will then take up the specified width, and the remaining space will be split equally between the left and right margins.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.