liveBook · Manning

Display property

As explained in Web Design Playground, Second Edition

The CSS display property specifies how an element participates in layout and whether it generates a box.

The display property tells the browser how an element joins the layout. Think of it as choosing whether an item behaves like a full-width block, a friendly inline block, or a grid container. section 9.2 section 13.10

Use the value that matches the layout job:

  • display: block makes an element a true block-level element. section 9.2
  • display: inline-block keeps an element flowing inline while allowing width, height, and other block-related properties. section 9.2
  • display: grid converts a block element into a grid container for arranging columns, rows, gaps, and named areas. section 13.10

A horizontal navigation menu

Set the list items to display: inline-block when you want navigation links to sit side by side while still accepting padding. Padding then adds breathing room so the links do not huddle together like nervous penguins. section 9.3

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

See the complete navigation rule using display: inline-block alongside list cleanup and spacing. section 9.3

How Web Design Playground, Second Edition covers it

How deep it goes
Defines three practical display uses through examples but does not detail the full display value set.
Examples
Uses element sizing and a padded horizontal navigation menu to demonstrate display behavior.
What you can do after
Apply display: block, display: inline-block, or display: grid to change an element's layout behavior.
How it connects
Connects display to block-level elements, inline elements, width, height, padding, and CSS Grid.

Also explained in

Compare how 2 books explain display property →

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.