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.

Syntaxblock | inline | run-in
Used bydisplay
Speccss-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.

Syntaxflow | flow-root | table | flex | grid | ruby
Used bydisplay
Speccss-display-4
ValueChildren are laid out with
flowNormal flow: blocks and inline text.
flow-rootNormal flow inside a new block formatting context, which contains floats and stops margin collapsing through the box.
tableThe table layout model.
flexFlex layout. See Flexbox.
gridGrid layout. See Grid.
rubyRuby 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 bydisplay
Speccss-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.

Syntaxtable-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 bydisplay
Speccss-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.

Syntaxcontents | none
Used bydisplay
Speccss-display-4
ValueEffect
noneThe element and all its descendants generate no boxes and take no space.
contentsThe 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.

Syntaxinline-block | inline-table | inline-flex | inline-grid
Used bydisplay
Speccss-display-4
Legacy keywordSame as
inline-blockinline flow-root
inline-tableinline table
inline-flexinline flex
inline-gridinline 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 bywidth, height, min-width, min-height, max-width, max-height, inline-size, block-size, column-width
Speccss-sizing-4
ValueSizeSupport
min-contentThe narrowest the content can be without overflowing: as if every soft wrap opportunity were taken.Chrome 46 · Firefox 66 · Safari 11
max-contentThe width the content would take with no wrapping at all.Chrome 46 · Firefox 66 · Safari 11
fit-contentThe available space, but no more than max-content and no less than min-content.Chrome 46 · Firefox 94 · Safari 11
stretchFill 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.

Syntaxnone | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
Used byborder-style, border, outline-style, column-rule-style
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4
ValueLine
noneNo line; the width computes to 0.
hiddenLike none, but in collapsed table borders it wins over every other style.
dottedA series of round dots.
dashedA series of short dashes.
solidA single solid line.
doubleTwo parallel lines with a gap; the lines and gap share the width.
grooveLooks carved into the page.
ridgeLooks raised out of the page.
insetThe box looks pressed into the page.
outsetThe 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 byborder-width, border, outline-width, column-rule-width
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-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.

Syntaxvisible | hidden | clip | scroll | auto
Used byoverflow, overflow-x, overflow-y, overflow-block, overflow-inline
SupportChrome 1 · Firefox 1 · Safari 1
clip: Chrome 90 · Firefox 81 · Safari 16
Speccss-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 byalign-items, align-self, align-content, justify-items, justify-self
Speccss-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.

Syntaxspace-between | space-around | space-evenly | stretch
Used byjustify-content, align-content, place-content
Speccss-align-3
ValueFree space goes
space-betweenEvenly between items, none at the ends.
space-aroundEvenly around each item, so the ends get half a gap.
space-evenlyInto equal gaps between items and at both ends.
stretchInto 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.

Syntaxcenter | start | end | flow-start | flow-end | flex-start | flex-end
Used byjustify-content, align-content, place-content
Speccss-align-3
ValuePacks towards
start, endThe start or end edge of the container in that axis, following the writing mode.
centerThe centre.
flex-start, flex-endIn 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.

Syntaxcenter | start | end | self-start | self-end | flow-start | flow-end | flex-start | flex-end
Used byalign-items, align-self, justify-items, justify-self, place-items, place-self
Speccss-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.

Syntaxunsafe | safe
Used byIn front of a position keyword in justify-content, align-content, align-items, align-self, justify-items, justify-self
Speccss-align-3

Supported in Chrome 115 · Firefox 63 · Safari 17.6.

justify-content: safe center;
Centre the items, unless that would push some out of reach.

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 bygrid-auto-columns, grid-auto-rows, and the track lists of grid-template-columns and grid-template-rows
Speccss-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 bygrid-template-columns, grid-template-rows, grid-template, grid
Speccss-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;
A fixed first column, three equal flexible columns, and one sized to its content.

<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 bygrid-template-columns, grid-template-rows, grid-template; names are referenced by grid-column, grid-row and grid-area
Speccss-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];
A centred content column with full-bleed lines either side.

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 byanchor-name, anchor-scope, position-anchor, and the anchor() and anchor-size() functions
Speccss-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 byposition-area, position-try-fallbacks
Speccss-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; }
Below the anchor, starting at its left edge and free to extend to the right.

<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.

Syntaxflip-block || flip-inline || flip-start || flip-x || flip-y
Used byposition-try-fallbacks
Speccss-anchor-position-1
TacticMirrors the positionSupport
flip-blockAcross the block axis: above becomes below in horizontal text.Chrome 128 · Firefox 147 · Safari 26
flip-inlineAcross the inline axis: left becomes right in horizontal text.Chrome 128 · Firefox 147 · Safari 26
flip-startAcross the diagonal from start-start to end-end, swapping the two axes.Chrome 128 · Firefox 147 · Safari 26
flip-xAcross the vertical axis, left to right, whatever the writing mode.Chrome 144 · Firefox 147 · Safari 26.2
flip-yAcross 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;
Try the other side vertically, then horizontally, then both.