Search⌘ K
AI Features

Solution: Horizontal Centering with margin: auto

Explore how to center block elements horizontally using CSS margin auto by setting left and right margins to auto. This technique helps you evenly distribute extra horizontal space and create balanced layouts within parent containers.

We'll cover the following...

Solution explanation

In the styles.css file, on line 8 (margin: 0 auto;), setting left and right margins to auto makes the block absorb any extra horizontal space equally, centering the .box within its container.