liveBook · Manning

Inline-block

As explained in Web Design Playground, Second Edition

An inline block is a CSS layout mode in which an element participates in inline flow while generating a block container for its contents.

inline-block lets an element stay in the inline flow while accepting block-style properties such as width and height. It is the useful middle ground between an inline element, which flows with text, and a block element, which starts on its own line. section 9.2

Use inline-block when you want an element to:

  • Remain alongside neighboring content instead of taking a full line. section 9.2
  • Accept width, height, padding, and other block-related properties. section 9.2
  • Create navigation items that display inline while behaving like blocks. section 9.3

A simple horizontal navigation bar

Remove the list bullets, then make each list item inline-block. Add right padding so the labels do not huddle together: ul { list-style-type: none; } li { display: inline-block; padding-right: 1em; } section 9.3

ul {
    list-style-type: none;
    text-transform: uppercase;
}
li {
    display: inline-block;
    padding-right: 1em;      #1
}

Inspect the complete CSS pattern for turning list items into readable horizontal navigation. section 9.3

How Web Design Playground, Second Edition covers it

How deep it goes
Defines the display behavior and demonstrates navigation spacing, but does not explore layout internals or edge cases.
Examples
Demonstrates unordered-list navigation with inline-block list items and right padding between labels.
What it assumes
Builds from the distinction between inline and block-level elements and their default sizing behavior.
What you can do after
Apply it via CSS to size inline elements and build spaced horizontal navigation menus.
How it connects
Connects inline-block with inline elements, block-level elements, width, height, padding, and navigation menus.

Also explained in

Compare how 4 books explain inline-block →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.