Blog Post

Margin: auto Challenges

The Zombie: Margin: auto without setting a width or display: block

Always a Zombie? Yes

Severity: medium-low

Why is it a zombie: It won’t work, but it won’t break your site either.

Cure the Zombie by: Ensure the element you’re centering with margin: auto; is set to display: block; and that a width has been set. If neither of those things happens the element won’t center, but it may not be clear why it’s not working.