Why is my background color not showing if I have display: inline?

The div doesn’t take up space if it’s inline. if you want an inline element that shows as the children’s height, then use display: inline-block;.

As for a good discussion, I’d trust QuirksMode‘s take better than my own. The gist is that an inline element doesn’t push other elements out of the way.

Leave a Comment