Email or username:

Password:

Forgot your password?
Top-level
Matt Wilcox

@jfml It's because of the difference between elements that use the `block` and `inline` boxes. developer.mozilla.org/en-US/do

`text-align: center;` means it centres the content of elements with an inline type - the text *inside* the p, for example. Not the p itself.

When you want to centre "an HTML element" you likely want to centre *the element* and not *its content*. Which means it needs to be block level, and then you can use margins.

2 comments
jfml ✨ Jonas Laugs

@mattwilcox Mmmh, ok. So text would be inline but images aren't?

Matt Wilcox

@jfml Yeah, this link should explain what the difference is and which applies to what.

developer.mozilla.org/en-US/do

Go Up