Course contentsShow
← Web Development
Lesson 210 of 2,9824. CSS Layout FoundationsFree lesson

Inline-Block Display

Combining inline flow behavior with block-level box model properties.

Inline-Block Display

What you'll learn: How to make elements flow inline like text while still accepting width, height, and margin like blocks.


The Best of Both Worlds

Remember how inline elements (like <span>) flow side-by-side but ignore width and height? And how block-level elements (like <div>) stack vertically but respect all box model properties?

display: inline-block gives you a hybrid: elements sit next to each other like inline elements, but you can apply width, height, padding, and margin like block-level boxes.

How It Works

When you set display: inline-block on an element, it behaves like an inline element from the outside (flows with surrounding content) but like a block from the inside (respects all dimensions).

.button {
  display: inline-block;
  width: 120px;
  height: 40px;
  padding: 10px;
  margin: 5px;
  background-color: blue;
  color: white;
}

This .button will sit next to other inline or inline-block elements, but you can control its exact size and spacing—something impossible with pure inline elements.

Common Use Cases

  • Navigational buttons that need specific dimensions but should sit side-by-side
  • Image thumbnails in a row with controlled spacing
  • Form elements aligned horizontally with consistent sizing

Think of It Like This

Imagine inline elements as words in a sentence—they flow together but can't grow bigger. Block elements are like paragraphs—they stack but can be any size. Inline-block elements are like Polaroid photos on a string: they hang side-by-side but each photo has its own defined width and height.


Key Takeaway: display: inline-block combines inline flow behavior with block-level box model control, perfect for creating side-by-side elements with precise dimensions.