Center a block with auto margins

Give the element a width, then let the side margins share the rest equally.

CSS · Center a block with auto marginsBeginner
.container {
  width: min(100% - 2rem, 1100px);
  margin-inline: auto;
}
centermargin autowidthcontainer