Layout values
The value types behind the layout properties: the parts of display, box sizes, border line styles and widths, overflow keywords, the alignment keywords shared by flexbox and grid, grid track lists, and the values used by anchor positioning. The properties themselves are under Box model, Flexbox, Grid and Anchor positioning.
Display
<display-outside>
The outer display type: how the box takes part in its parent's layout. A block box starts on a new line and fills the available width; an inline box flows along a line of text.
| Syntax | block | inline | run-in |
|---|---|
| Used by | display |
| Spec | css-display-4 |
On its own, an outer type implies flow inside. With an inner type it forms a two-keyword value such as inline flex, supported in Chrome 115 · Firefox 70 · Safari 15.
<display-inside>
The inner display type: which layout the box uses for its own children. On its own, an inner type implies block outside, so display: grid is display: block grid.
| Syntax | flow | flow-root | table | flex | grid | ruby |
|---|---|
| Used by | display |
| Spec | css-display-4 |
| Value | Children are laid out with |
|---|---|
flow | Normal flow: blocks and inline text. |
flow-root | Normal flow inside a new block formatting context, which contains floats and stops margin collapsing through the box. |
table | The table layout model. |
flex | Flex layout. See Flexbox. |
grid | Grid layout. See Grid. |
ruby | Ruby annotation layout. Chrome 121 · Firefox 38 · Safari no. |
<display-listitem>
A box that generates a ::marker as well as its normal box, the way <li> elements do. The keyword list-item can be combined with an outer type and with flow or flow-root.
| Syntax | <display-outside>? && [ flow | flow-root ]? && list-item |
|---|---|
| Used by | display |
| Spec | css-display-4 |
display: list-item is a block list item; display: inline list-item puts list items side by side while keeping their markers. Each list item also increments the built-in list-item counter.
<display-internal>
The roles of the parts inside a table or ruby layout. They let other elements stand in for table rows and cells, but only make sense inside a parent with the matching layout; on their own, the browser wraps them in the missing parent boxes.
| Syntax | table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby-base | ruby-text | ruby-base-container | ruby-text-container |
|---|---|
| Used by | display |
| Spec | css-display-4 |
The table-* values work in every browser and match the HTML table elements: table-row for <tr>, table-cell for <td>, table-header-group for <thead> and so on. ruby-text is in Chrome 121 and Firefox 38; ruby-base and the two container values are in Firefox only.
<display-box>
Whether the element generates a box at all.
| Syntax | contents | none |
|---|---|
| Used by | display |
| Spec | css-display-4 |
| Value | Effect |
|---|---|
none | The element and all its descendants generate no boxes and take no space. |
contents | The element's own box disappears and its children take part in the parent's layout directly, for example as grid items. Chrome 65 · Firefox 37 · Safari 11.1. |
<display-legacy>
Single-keyword names for inline-level versions of the inner types, kept from before two-keyword values existed. Each has a two-keyword equivalent.
| Syntax | inline-block | inline-table | inline-flex | inline-grid |
|---|---|
| Used by | display |
| Spec | css-display-4 |
| Legacy keyword | Same as |
|---|---|
inline-block | inline flow-root |
inline-table | inline table |
inline-flex | inline flex |
inline-grid | inline grid |
Sizing, borders & overflow
<box-size>
A preferred, minimum or maximum size for a box: a non-negative length or percentage, or a keyword that sizes the box from its content or its container.
| Syntax | <length-percentage [0,∞]> | stretch | contain | min-content | max-content | fit-content | stretch(<length-percentage [0,∞]>) | fit-content(<length-percentage [0,∞]>) | <calc-size()> |
|---|---|
| Used by | width, height, min-width, min-height, max-width, max-height, inline-size, block-size, column-width |
| Spec | css-sizing-4 |
| Value | Size | Support |
|---|---|---|
min-content | The narrowest the content can be without overflowing: as if every soft wrap opportunity were taken. | Chrome 46 · Firefox 66 · Safari 11 |
max-content | The width the content would take with no wrapping at all. | Chrome 46 · Firefox 66 · Safari 11 |
fit-content | The available space, but no more than max-content and no less than min-content. | Chrome 46 · Firefox 94 · Safari 11 |
stretch | Fill the containing block, less the box's own margins. | Chrome 138 · Firefox no · Safari 27 |
calc-size() | Arithmetic on an intrinsic size, which also lets height: auto be animated. | Chrome 129 · Firefox no · Safari no |
<line-style>
The pattern of a border, outline or column rule. Most styles need a width of at least a few pixels to be visible as anything other than a solid line.
| Syntax | none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset |
|---|---|
| Used by | border-style, border, outline-style, column-rule-style |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-borders-4 |
| Value | Line |
|---|---|
none | No line; the width computes to 0. |
hidden | Like none, but in collapsed table borders it wins over every other style. |
dotted | A series of round dots. |
dashed | A series of short dashes. |
solid | A single solid line. |
double | Two parallel lines with a gap; the lines and gap share the width. |
groove | Looks carved into the page. |
ridge | Looks raised out of the page. |
inset | The box looks pressed into the page. |
outset | The box looks raised out of the page. |
<line-width>
The thickness of a border, outline or rule: a non-negative length, or one of the keywords thin, medium and thick. The keywords are commonly 1px, 3px and 5px.
| Syntax | <length [0,∞]> | hairline | thin | medium | thick |
|---|---|
| Used by | border-width, border, outline-width, column-rule-width |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-borders-4 |
The initial border width is medium, but a border whose style is none or hidden always has a used width of 0. Widths are snapped to whole device pixels.
<overflow>
The keywords for what happens to content that does not fit its box: show it, clip it, or clip it and allow scrolling. Each value is described under overflow.
| Syntax | visible | hidden | clip | scroll | auto |
|---|---|
| Used by | overflow, overflow-x, overflow-y, overflow-block, overflow-inline |
| Support | Chrome 1 · Firefox 1 · Safari 1clip: Chrome 90 · Firefox 81 · Safari 16 |
| Spec | css-overflow-3 |
Browsers also accept overlay as a legacy alias for auto; it is deprecated, so write auto.
Alignment
<baseline-position>
Aligns items by their text baselines instead of their edges, so text in items of different sizes lines up. first baseline (the same as baseline) uses the first line of text, last baseline the last.
| Syntax | [ first | last ]? && baseline |
|---|---|
| Used by | align-items, align-self, align-content, justify-items, justify-self |
| Spec | css-align-3 |
last baseline arrived later than the rest: Chrome 108 · Firefox 52 · Safari 16.2.
<content-distribution>
Shares the free space in a flex or grid container between and around its lines, tracks or items.
| Syntax | space-between | space-around | space-evenly | stretch |
|---|---|
| Used by | justify-content, align-content, place-content |
| Spec | css-align-3 |
| Value | Free space goes |
|---|---|
space-between | Evenly between items, none at the ends. |
space-around | Evenly around each item, so the ends get half a gap. |
space-evenly | Into equal gaps between items and at both ends. |
stretch | Into the auto-sized tracks or lines, which grow to fill it. |
<content-position>
Packs the content of a flex or grid container as a whole towards one side or the centre.
| Syntax | center | start | end | flow-start | flow-end | flex-start | flex-end |
|---|---|
| Used by | justify-content, align-content, place-content |
| Spec | css-align-3 |
| Value | Packs towards |
|---|---|
start, end | The start or end edge of the container in that axis, following the writing mode. |
center | The centre. |
flex-start, flex-end | In a flex container, the start or end of the flex direction, which flips with row-reverse and column-reverse. Elsewhere, the same as start and end. |
<self-position>
Places one item within its own alignment area: its grid area, or the cross size of its flex line.
| Syntax | center | start | end | self-start | self-end | flow-start | flow-end | flex-start | flex-end |
|---|---|
| Used by | align-items, align-self, justify-items, justify-self, place-items, place-self |
| Spec | css-align-3 |
The values mean the same as in <content-position>. self-start and self-end use the item's own writing mode instead of the container's, which matters when an item has a different direction or writing-mode.
<overflow-position>
A modifier for what to do when an aligned item is bigger than its container. safe switches to start alignment if the item would otherwise overflow off the start edge, where it could not be scrolled to; unsafe keeps the requested alignment regardless.
| Syntax | unsafe | safe |
|---|---|
| Used by | In front of a position keyword in justify-content, align-content, align-items, align-self, justify-items, justify-self |
| Spec | css-align-3 |
Supported in Chrome 115 · Firefox 63 · Safari 17.6.
justify-content: safe center;
Grid
<track-size>
The size of one grid row or column. A track can have a single breadth, a minimum and maximum with minmax(), or grow to its content up to a limit with fit-content().
| Syntax | <track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( <length-percentage [0,∞]> ) |
|---|---|
| Used by | grid-auto-columns, grid-auto-rows, and the track lists of grid-template-columns and grid-template-rows |
| Spec | css-grid-2 |
A <track-breadth> is a non-negative <length-percentage>, a <flex> value in fr, min-content, max-content or auto. The minimum in minmax() cannot be an fr value. See Grid & sizing for minmax() and fit-content().
<track-list>
The explicit tracks of a grid in one axis: a series of track sizes and repeat() groups, with optional line names between them.
| Syntax | [ <line-names>? [ <track-size> | <track-repeat> ] ]+ <line-names>? |
|---|---|
| Used by | grid-template-columns, grid-template-rows, grid-template, grid |
| Spec | css-grid-2 |
<track-repeat> is repeat() with a whole number of repetitions. A list that uses repeat(auto-fill, …) or repeat(auto-fit, …) is the related <auto-track-list>, which allows one such automatic repeat among fixed-size tracks.
grid-template-columns: 12rem repeat(3, 1fr) auto;
<line-names>
Names for a grid line, written in square brackets between track sizes. A line can have several names, and items can then be placed by name instead of by number.
| Syntax | '[' <custom-ident>* ']' |
|---|---|
| Used by | grid-template-columns, grid-template-rows, grid-template; names are referenced by grid-column, grid-row and grid-area |
| Spec | css-grid-2 |
The quoted '[' and ']' in the grammar mean literal bracket characters. Lines named x-start and x-end can be referred to together as x, so grid-column: content spans from content-start to content-end in the example below.
grid-template-columns: [full-start] 1fr [content-start] minmax(0, 60rem) [content-end] 1fr [full-end];
Anchor positioning
<anchor-name>
The name of an anchor element, which positioned elements can then attach to. It is a <dashed-ident>, so it always starts with --.
| Syntax | <dashed-ident> |
|---|---|
| Used by | anchor-name, anchor-scope, position-anchor, and the anchor() and anchor-size() functions |
| Spec | css-anchor-position-1 |
<position-area>
Places an anchored element in a cell of a 3×3 grid drawn around its anchor, or across several cells with the span- keywords. Physical (top, left), logical (block-start, inline-end) and shorthand (start, end) forms are all accepted; center is the middle row or column.
| Syntax | [ [ left | center | right | span-left | span-right | x-start | x-end | span-x-start | span-x-end | self-x-start | self-x-end | span-self-x-start | span-self-x-end | span-all ] || [ top | center | bottom | span-top | span-bottom | y-start | y-end | span-y-start | span-y-end | self-y-start | self-y-end | span-self-y-start | span-self-y-end | span-all ] | [ block-start | center | block-end | span-block-start | span-block-end | span-all ] || [ inline-start | center | inline-end | span-inline-start | span-inline-end | span-all ] | [ self-block-start | center | self-block-end | span-self-block-start | span-self-block-end | span-all ] || [ self-inline-start | center | self-inline-end | span-self-inline-start | span-self-inline-end | span-all ] | [ start | center | end | span-start | span-end | span-all ]{1,2} | [ self-start | center | self-end | span-self-start | span-self-end | span-all ]{1,2} ] |
|---|---|
| Used by | position-area, position-try-fallbacks |
| Spec | css-anchor-position-1 |
One keyword from each axis picks a cell. A single keyword such as top spans all three cells of the other axis, so the element sits above the anchor, centred on it. A span- keyword covers the named cell plus the centre cell, and span-all covers all three.
.tooltip { position: absolute; position-anchor: --button; position-area: block-end span-inline-end; }
<try-tactic>
A way of deriving a fallback position by mirroring the element's current position. When the element would overflow, the browser tries the flipped position instead.
| Syntax | flip-block || flip-inline || flip-start || flip-x || flip-y |
|---|---|
| Used by | position-try-fallbacks |
| Spec | css-anchor-position-1 |
| Tactic | Mirrors the position | Support |
|---|---|---|
flip-block | Across the block axis: above becomes below in horizontal text. | Chrome 128 · Firefox 147 · Safari 26 |
flip-inline | Across the inline axis: left becomes right in horizontal text. | Chrome 128 · Firefox 147 · Safari 26 |
flip-start | Across the diagonal from start-start to end-end, swapping the two axes. | Chrome 128 · Firefox 147 · Safari 26 |
flip-x | Across the vertical axis, left to right, whatever the writing mode. | Chrome 144 · Firefox 147 · Safari 26.2 |
flip-y | Across the horizontal axis, top to bottom, whatever the writing mode. | Chrome 144 · Firefox 147 · Safari 26.2 |
position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;