Positioning, floats & columns

The properties that take a box out of normal flow and place it, float it to one side for text to wrap round, flow content into columns, and control where content breaks between columns and pages. The flow-relative insets (inset-block, inset-inline-start and so on) are under Writing modes & logical; placing a box against another element is under Anchor positioning; column-gap and column-rule are under Gaps.

Positioning

position

Chooses the positioning scheme for a box: whether it stays in normal flow, and what the inset properties (top, left, inset and so on) measure from.

Syntaxstatic | relative | absolute | sticky | fixed | <running()>
Initialstatic
Applies toAll elements except table column groups and table columns
InheritedNo
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-position-3
ValueEffect
staticNormal flow. The inset properties have no effect.
relativeLaid out in normal flow, then shifted by the insets. Its original space is kept, so nothing around it moves.
absoluteTaken out of flow and placed by the insets against its containing block: usually the nearest ancestor whose position is not static.
fixedLike absolute, but placed against the viewport, so it stays put when the page scrolls. An ancestor with a transform or filter becomes its containing block instead.
stickyStays in normal flow until scrolling would carry it past the inset you set, then sticks at that inset within its nearest scrolling ancestor, never leaving its own containing block.

Any value other than static makes the box a containing block for absolutely positioned descendants. sticky arrived later: Chrome 56 · Firefox 32 · Safari 13.

top, right, bottom, left

The distance of a positioned box's edge from the matching edge of its containing block (or, for relative, how far to shift the box from where it would have been). anchor() and anchor-size() let the value refer to an anchor element; see Values & references.

Syntaxauto | <length-percentage> | <anchor()> | <anchor-size()>
Initialauto
Applies toPositioned elements
InheritedNo
PercentagesRefer to the height (top, bottom) or width (left, right) of the containing block
AnimationBy computed value type
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-position-3

When both opposite insets are set on an absolutely positioned box with an auto size, the box stretches between them.

inset

Shorthand for top, right, bottom and left, taking one to four values in the same order as margin.

Syntax<'top'>{1,4}
Initialauto
Applies toPositioned elements
InheritedNo
PercentagesSee individual properties
AnimationBy computed value type
SupportChrome 87 · Firefox 66 · Safari 14.1
Speccss-position-3
position: absolute;
inset: 0;
Cover the whole containing block, for an overlay or backdrop.

z-index

The stacking order of a positioned box within its stacking context: higher values paint in front of lower ones. An integer value also makes the box start a new stacking context, so its descendants are stacked inside it and cannot rise above its siblings.

Syntaxauto | <integer> | inherit
Initialauto
Applies toPositioned elements
InheritedNo
AnimationBy computed value type
SupportChrome 1 · Firefox 1 · Safari 1
Speccss2

z-index also works on flex items and grid items, even when they are not positioned.

Floats & shapes

float

Moves a box to one side of its container and lets inline content, such as text, wrap round the other side. Floats have no effect on absolutely positioned boxes or on flex and grid items.

Syntaxblock-start | block-end | inline-start | inline-end | snap-block | <snap-block()> | snap-inline | <snap-inline()> | left | right | top | bottom | none | footnote
Initialnone
Applies toAll elements
InheritedNo
AnimationBy computed value type
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-page-floats-3

Browsers support left, right and none, and the flow-relative inline-start and inline-end (Chrome 118 · Firefox 55 · Safari 15). The other values in the grammar belong to page floats, which no browser ships. A container with display: flow-root grows to contain its floats.

clear

Moves a box down below any earlier floats on the given side, so it starts on a clear line.

Syntaxinline-start | inline-end | block-start | block-end | left | right | top | bottom | both-inline | both-block | both | none
Initialnone
Applies toBlock-level elements, floats, regions and pages
InheritedNo
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-page-floats-3

Browsers support left, right, both and none, and the flow-relative inline-start and inline-end (Chrome 118 · Firefox 55 · Safari 15).

shape-outside

Gives a float a non-rectangular outline for text to wrap round: a basic shape such as circle() or polygon(), one of the float's boxes, or the opaque parts of an image. The float itself still paints as a rectangle; combine it with clip-path to cut the visible shape too.

Syntaxnone | [ <basic-shape> || <shape-box> ] | <image>
Initialnone
Applies toFloats and initial letter boxes
InheritedNo
AnimationAs defined for <basic-shape>, otherwise discrete
SupportChrome 37 · Firefox 62 · Safari 10.1
Speccss-shapes-1
.portrait {
  float: left;
  shape-outside: circle(50%);
  shape-margin: 1rem;
}
Text wraps round a round portrait, keeping 1rem clear of it.

The shape functions are listed under Shapes & images.

shape-margin

Adds space round the shape set by shape-outside, pushing wrapping text further away from it.

Syntax<length-percentage [0,∞]>
Initial0
Applies toFloats and initial letter boxes
InheritedNo
PercentagesRefer to the inline size of the containing block
AnimationBy computed value
SupportChrome 37 · Firefox 62 · Safari 10.1
Speccss-shapes-1

shape-image-threshold

When shape-outside is an image, sets the alpha level that counts as part of the shape: pixels more opaque than the threshold are inside it. 0.5 ignores pixels that are half transparent or less.

Syntax<opacity-value>
Initial0
Applies toFloats
InheritedNo
AnimationBy computed value
SupportChrome 37 · Firefox 62 · Safari 10.1
Speccss-shapes-1

An <opacity-value> is a number or a percentage, clamped to the range 0 to 1.

Multi-column

columns

Shorthand for column-width and column-count, with an optional column-height after a slash. Setting either the width or the count makes the box a multi-column container. The gap and rule between columns are set with column-gap and column-rule.

Syntax[ <'column-width'> || <'column-count'> ] [ / <'column-height'> ]?
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
PercentagesSee individual properties
AnimationSee individual properties
SupportChrome 50 · Firefox 52 · Safari 9
Speccss-multicol-2
columns: 18rem 3;
Up to three columns, each at least 18rem wide; fewer when the container is narrow.

The / column-height part is newer: Chrome 145 · Firefox no · Safari no.

column-count

The number of columns. With a column-width as well, it is the maximum number.

Syntaxauto | <integer [1,∞]>
Initialauto
Applies toBlock containers except table wrapper boxes
InheritedNo
AnimationBy computed value
SupportChrome 50 · Firefox 52 · Safari 9
Speccss-multicol-2

column-width

The ideal width of each column. The browser fits as many columns of at least this width as the container allows, then widens them to share out the leftover space.

Syntaxauto | <length [0,∞]>
Initialauto
Applies toBlock containers except table wrapper boxes
InheritedNo
AnimationBy computed value type
SupportChrome 50 · Firefox 50 · Safari 9
Speccss-multicol-2

column-fill

How content is shared between columns when the container's height is constrained. balance evens out the content so the columns end at about the same height; auto fills each column in turn, which can leave the last ones short or empty.

Syntaxauto | balance | balance-all
Initialbalance
Applies toMulticol containers
InheritedNo
AnimationDiscrete
SupportChrome 50 · Firefox 52 · Safari 9
Speccss-multicol-2

column-span

Lets an element inside a multi-column container break out and span every column, such as a heading across the top of an article. Browsers support none and all.

Syntaxnone | <integer [1,∞]> | all | auto
Initialnone
Applies toIn-flow block-level elements
InheritedNo
AnimationDiscrete
SupportChrome 50 · Firefox 71 · Safari 9
Speccss-multicol-2
article h2 { column-span: all; }
Headings run across all the columns; the text before and after them flows in columns.

column-height

A fixed height for each column. Content that does not fit in one row of columns can then wrap into a new row of columns below, as set by column-wrap.

Syntaxauto | <length [0,∞]>
Initialauto
Applies toBlock containers except table wrapper boxes
InheritedNo
AnimationBy computed value type
SupportChrome 145 · Firefox no · Safari no
Speccss-multicol-2

column-wrap

Whether extra content goes into a new row of columns below the first (wrap) or into further columns that overflow in the inline direction (nowrap). auto wraps only when column-height is set.

Syntaxauto | nowrap | wrap
Initialauto
Applies toMulticol containers
InheritedNo
AnimationDiscrete
SupportChrome 145 · Firefox no · Safari no
Speccss-multicol-2

Fragmentation & pages

break-before, break-after

Asks for, or tries to avoid, a page or column break before or after a box, in printed output and in multi-column layout.

Syntaxauto | avoid | always | all | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region
Initialauto
Applies toBlock-level boxes, grid items, flex items, table row groups and table rows (but see prose)
InheritedNo
AnimationDiscrete
SupportChrome 50 · Firefox 65 · Safari 10
Speccss-break-4
ValueEffect
autoNeither forces nor avoids a break.
pageForces a page break.
left / rightForces one or two page breaks so the next page is a left or right page.
recto / versoLike right / left, but relative to the page progression of the document.
columnForces a column break.
avoid, avoid-page, avoid-columnAvoids any break, a page break, or a column break here.

Support for the individual values varies: Firefox has no column values and no avoid values, and Safari does not support avoid.

h2 { break-before: page; }
Start every chapter on a new printed page.

break-inside

Tries to keep a box in one piece rather than splitting it across pages or columns. Useful for figures, cards and table rows.

Syntaxauto | avoid | avoid-page | avoid-column | avoid-region
Initialauto
Applies toAll elements except inline-level boxes, internal ruby boxes, table column boxes, table column group boxes and absolutely positioned boxes
InheritedNo
AnimationDiscrete
SupportChrome 50 · Firefox 65 · Safari 10
Speccss-break-4
.card { break-inside: avoid; }
Keep each card whole within a single column.

orphans, widows

The fewest lines of a paragraph that may be left alone at the bottom of a page or column (orphans) or carried over to the top of the next one (widows). If a break would leave fewer, the break moves.

Syntax<integer [1,∞]>
Initial2
Applies toBlock containers that establish an inline formatting context
InheritedYes
AnimationBy computed value type
SupportChrome 25 · Firefox no · Safari 1.3
Speccss-break-4

box-decoration-break

What happens to a box's borders, padding, background and shadow when it is split across lines, columns or pages. slice cuts the box as if it were one long piece; clone gives each fragment its own full set, so a highlighted inline span wrapping onto two lines gets rounded ends on both.

Syntaxslice | clone
Initialslice
Applies toAll elements
InheritedNo
AnimationDiscrete
SupportChrome 130 · Firefox 32 · Safari no
Speccss-break-4

page

Names the type of page a box should be printed on, so that an @page rule with that name can style it. When the value changes between neighbouring boxes, a page break is forced between them.

Syntaxauto | <custom-ident>
Initialauto
Applies toBoxes that create class A break points
InheritedNo (but see prose)
AnimationDiscrete
SupportChrome 85 · Firefox 110 · Safari 1
Speccss-page-3

Class A break points are the places between sibling block-level boxes. A box with page: auto uses the page of its parent.

@page wide { size: landscape; }
table.big { page: wide; }
Print a large table on its own landscape page.

page-break-before, page-break-after Deprecated

The CSS 2 page-break properties. Browsers now treat them as aliases of break-before and break-after, with always meaning page. Use break-before and break-after instead.

Syntaxauto | always | avoid | left | right | inherit
Initialauto
Applies toBlock-level elements (but see text)
InheritedNo
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1.2
Speccss2

page-break-inside Deprecated

The CSS 2 property for avoiding a page break inside a box, now treated as an alias of break-inside. Use break-inside instead.

Syntaxavoid | auto | inherit
Initialauto
Applies toBlock-level elements (but see text)
InheritedNo
AnimationDiscrete
SupportChrome 1 · Firefox 19 · Safari 1.3
Speccss2