Centering Elements on the Page

One of the best resources, but might be a little advanced to start.

Using a width and left and right margins of auto

  • set a width on the element

  • set the margin-left and margin-right to auto

Using flex and align-items, justify-content of center

You can use the flex-direction property to set the child elements to flow across the row or down a single column.

Last updated

Was this helpful?