Layout

display

Choose how an element participates in flow and lays out its children.

Overview

ClassDeclarations
hiddendisplay: none;
flexdisplay: flex;
griddisplay: grid;
inlinedisplay: inline;
blockdisplay: block;
tabledisplay: table;
contentsdisplay: contents;
flow-rootdisplay: flow-root;
list-itemdisplay: list-item;
inline-blockdisplay: inline-block;
inline-flexdisplay: inline-flex;
inline-griddisplay: inline-grid;
inline-tabledisplay: inline-table;
table-celldisplay: table-cell;
table-captiondisplay: table-caption;
table-rowdisplay: table-row;
table-columndisplay: table-column;
table-row-groupdisplay: table-row-group;
table-column-groupdisplay: table-column-group;
table-header-groupdisplay: table-header-group;
table-footer-groupdisplay: table-footer-group;
display:<type>display: <type>;

Basic usage

Block and inline boxes

Use block to start a new block, inline to participate in the surrounding text, and inline-block for an inline box that accepts width and height. Compare where the text before and after each specimen ends up.

Block and inline boxes
A block starts a new line. Inline and inline-block boxes remain beside the surrounding text.
<div>  Block elements start on a new line.  <span class="block">    display:block  </span>  Inline elements stay in text flow.  <span class="inline">    display:inline  </span>  Inline-block elements accept dimensions.  <span class="inline-block">    display:inline-block  </span>  Choose the display mode for the layout.</div>

Flex

Use flex when direct children should share one row or column. The container itself participates in the outer layout as a block.

Flex
The three direct children share a flex row with the authored gap.
<div class="flex items-center gap-sm">  <div>01</div>  <div>02</div>  <div>03</div></div>

Inline flex

Use inline-flex for a badge or compact control whose children need flex alignment while the whole object stays in a line of text.

Inline flex
The badge aligns its children with flex while staying in the paragraph’s line of text.
<p>  Status: <span class="inline-flex items-center gap-xs">    <span aria-hidden="true">●</span><span>In progress</span>  </span> while the next task is queued.</p>

Grid

Use grid to place direct children in rows and columns. Define tracks with grid-template-columns or grid-template-rows.

Grid
Four direct children occupy two explicitly defined grid columns.
<div class="grid grid-template-columns:repeat(2,auto) gap-sm">  <div>01</div>  <div>02</div>  <div>03</div>  <div>04</div></div>

Inline grid

Use inline-grid when a small grid should sit within text or beside other inline content. Its children use grid layout; the grid itself remains inline.

Inline grid
The four cells form a grid inside one inline box; the paragraph continues beside it.
<p>  Before <span class="inline-grid grid-template-columns:repeat(2,auto) gap-sm">    <span>01</span><span>02</span>    <span>03</span><span>04</span>  </span> after.</p>

Table

Table display values reproduce the visual table layout model. Use native <table>, <tr>, <th> and <td> elements for tabular data: CSS display values do not supply their accessibility semantics.

Table
Header, body and footer groups share the same table columns. This CSS-only structure has no native table semantics.
<div class="table">  <div class="table-caption">Orders</div>  <div class="table-header-group">    <div class="table-row">      <div class="table-cell">Product</div>      <div class="table-cell">Qty</div>      <div class="table-cell">Price</div>    </div>  </div>  <div class="table-row-group">    <div class="table-row">      <div class="table-cell">Milk</div>      <div class="table-cell">2</div>      <div class="table-cell">10.00</div>    </div>    <div class="table-row">      <div class="table-cell">Cola</div>      <div class="table-cell">3</div>      <div class="table-cell">12.00</div>    </div>    <div class="table-row">      <div class="table-cell">Juice</div>      <div class="table-cell">5</div>      <div class="table-cell">18.00</div>    </div>  </div>  <div class="table-footer-group">    <div class="table-row">      <div class="table-cell">Total</div>      <div class="table-cell text-center">10</div>      <div class="table-cell text-center">40.00</div>    </div>  </div></div>

Contents

Use contents to omit a wrapper’s own layout box. Its children then participate directly in the parent’s layout. The wrapper remains in the DOM, but its own background, border and dimensions no longer produce a box.

Contents
The violet items belong to the contents wrapper. All four items participate in the outer flex layout.
<div class="flex gap:1.25rem">  <div class="flex:1">01</div>  <div class="contents">    <div class="flex:1">02</div>    <div class="flex:1">03</div>  </div>  <div class="flex:1">04</div></div>

Flow root

Use flow-root on a wrapper that should contain its floated children. It establishes a block formatting context without using overflow clipping.

Flow root
The outlined parent contains the floated image as well as the paragraph.
<div class="flow-root">  <img class="float:left w:8rem mr-md" src="/demo/landscape.svg" alt="Landscape">  <p>The paragraph wraps around the floated image.</p></div>

List items

Use list-item to generate a list-item box and marker. Prefer <ul> or <ol> with <li> for semantic lists; this utility controls their visual display.

List items
Each element produces its own list marker. Use native list elements when the content is a semantic list.
<div>  <div class="list-item">01</div>  <div class="list-item">02</div>  <div class="list-item">03</div></div>

Hidden

Use hidden to apply display:none. The element and its descendants produce no layout boxes and are absent from the accessibility tree. Use visibility when its space should remain.

Hidden
Item 02 is still in the DOM, but display:none removes its box and its space.
<div class="flex gap:1.25rem">  <div>01</div>  <div class="hidden">02</div>  <div>03</div></div>

Apply conditionally

Switch the same items from a grid to a flex row on screens at sm, then use ordinary block flow in print. Combining screen and sm keeps the wide-screen rule from also applying to wide printed pages. Read conditions for breakpoint and media syntax.

Apply conditionally
display: Apply conditionally controls
Resize to switch between grid and flex. Print preview uses ordinary block flow at every page width.
<div class="grid grid-cols:2 gap-sm block@print flex@screen@sm">  <div>01</div>  <div>02</div>  <div>03</div></div>


© 2026 Aoyue Design LLC.MIT License
Trademark Policy