--- name: layout-display description: Controlling element display type including flex, grid, block, inline, hidden, and sr-only --- # Display Utilities for controlling the display box type of an element. ## Usage ### Basic display types ```html display: inline display: inline-block
display: block
``` ### Flex and Grid containers ```html
Flex layout
Inline flex with text
Grid layout
Inline grid ``` ### Flow root Use `flow-root` to create a block-level element with its own block formatting context (fixes margin collapse): ```html
Content with isolated BFC
``` ### Contents Use `contents` for a "phantom" container whose children act like direct children of the parent: ```html
01
02
03
04
``` ### Table display ```html
Header 1
Header 2
Cell 1
Cell 2
``` ### Hidden ```html ``` For visual-only hiding while keeping in DOM, use `invisible` or `opacity-0` instead. ### Screen reader only ```html Settings ``` Use `not-sr-only` to undo: `Settings` ## Key Points - `flex` / `inline-flex` - Flexbox layout - `grid` / `inline-grid` - CSS Grid layout - `block` / `inline` / `inline-block` - Basic flow - `hidden` - `display: none` (removes from flow) - `sr-only` - Visually hidden but accessible to screen readers - `contents` - Children participate in parent's layout - `flow-root` - Establishes new BFC - Table utilities: `table`, `table-row`, `table-cell`, `table-header-group`, etc.