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.
| Syntax | static | relative | absolute | sticky | fixed | <running()> |
|---|---|
| Initial | static |
| Applies to | All elements except table column groups and table columns |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-position-3 |
| Value | Effect |
|---|---|
static | Normal flow. The inset properties have no effect. |
relative | Laid out in normal flow, then shifted by the insets. Its original space is kept, so nothing around it moves. |
absolute | Taken out of flow and placed by the insets against its containing block: usually the nearest ancestor whose position is not static. |
fixed | Like 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. |
sticky | Stays 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.
| Syntax | auto | <length-percentage> | <anchor()> | <anchor-size()> |
|---|---|
| Initial | auto |
| Applies to | Positioned elements |
| Inherited | No |
| Percentages | Refer to the height (top, bottom) or width (left, right) of the containing block |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-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} |
|---|---|
| Initial | auto |
| Applies to | Positioned elements |
| Inherited | No |
| Percentages | See individual properties |
| Animation | By computed value type |
| Support | Chrome 87 · Firefox 66 · Safari 14.1 |
| Spec | css-position-3 |
position: absolute;
inset: 0;
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.
| Syntax | auto | <integer> | inherit |
|---|---|
| Initial | auto |
| Applies to | Positioned elements |
| Inherited | No |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css2 |
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.
| Syntax | block-start | block-end | inline-start | inline-end | snap-block | <snap-block()> | snap-inline | <snap-inline()> | left | right | top | bottom | none | footnote |
|---|---|
| Initial | none |
| Applies to | All elements |
| Inherited | No |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-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.
| Syntax | inline-start | inline-end | block-start | block-end | left | right | top | bottom | both-inline | both-block | both | none |
|---|---|
| Initial | none |
| Applies to | Block-level elements, floats, regions and pages |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-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.
| Syntax | none | [ <basic-shape> || <shape-box> ] | <image> |
|---|---|
| Initial | none |
| Applies to | Floats and initial letter boxes |
| Inherited | No |
| Animation | As defined for <basic-shape>, otherwise discrete |
| Support | Chrome 37 · Firefox 62 · Safari 10.1 |
| Spec | css-shapes-1 |
.portrait {
float: left;
shape-outside: circle(50%);
shape-margin: 1rem;
}
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,∞]> |
|---|---|
| Initial | 0 |
| Applies to | Floats and initial letter boxes |
| Inherited | No |
| Percentages | Refer to the inline size of the containing block |
| Animation | By computed value |
| Support | Chrome 37 · Firefox 62 · Safari 10.1 |
| Spec | css-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> |
|---|---|
| Initial | 0 |
| Applies to | Floats |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 37 · Firefox 62 · Safari 10.1 |
| Spec | css-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'> ]? |
|---|---|
| Initial | See individual properties |
| Applies to | See individual properties |
| Inherited | See individual properties |
| Percentages | See individual properties |
| Animation | See individual properties |
| Support | Chrome 50 · Firefox 52 · Safari 9 |
| Spec | css-multicol-2 |
columns: 18rem 3;
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.
| Syntax | auto | <integer [1,∞]> |
|---|---|
| Initial | auto |
| Applies to | Block containers except table wrapper boxes |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 50 · Firefox 52 · Safari 9 |
| Spec | css-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.
| Syntax | auto | <length [0,∞]> |
|---|---|
| Initial | auto |
| Applies to | Block containers except table wrapper boxes |
| Inherited | No |
| Animation | By computed value type |
| Support | Chrome 50 · Firefox 50 · Safari 9 |
| Spec | css-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.
| Syntax | auto | balance | balance-all |
|---|---|
| Initial | balance |
| Applies to | Multicol containers |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 50 · Firefox 52 · Safari 9 |
| Spec | css-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.
| Syntax | none | <integer [1,∞]> | all | auto |
|---|---|
| Initial | none |
| Applies to | In-flow block-level elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 50 · Firefox 71 · Safari 9 |
| Spec | css-multicol-2 |
article h2 { column-span: all; }
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.
| Syntax | auto | <length [0,∞]> |
|---|---|
| Initial | auto |
| Applies to | Block containers except table wrapper boxes |
| Inherited | No |
| Animation | By computed value type |
| Support | Chrome 145 · Firefox no · Safari no |
| Spec | css-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.
| Syntax | auto | nowrap | wrap |
|---|---|
| Initial | auto |
| Applies to | Multicol containers |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 145 · Firefox no · Safari no |
| Spec | css-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.
| Syntax | auto | avoid | always | all | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region |
|---|---|
| Initial | auto |
| Applies to | Block-level boxes, grid items, flex items, table row groups and table rows (but see prose) |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 50 · Firefox 65 · Safari 10 |
| Spec | css-break-4 |
| Value | Effect |
|---|---|
auto | Neither forces nor avoids a break. |
page | Forces a page break. |
left / right | Forces one or two page breaks so the next page is a left or right page. |
recto / verso | Like right / left, but relative to the page progression of the document. |
column | Forces a column break. |
avoid, avoid-page, avoid-column | Avoids 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; }
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.
| Syntax | auto | avoid | avoid-page | avoid-column | avoid-region |
|---|---|
| Initial | auto |
| Applies to | All elements except inline-level boxes, internal ruby boxes, table column boxes, table column group boxes and absolutely positioned boxes |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 50 · Firefox 65 · Safari 10 |
| Spec | css-break-4 |
.card { break-inside: avoid; }
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,∞]> |
|---|---|
| Initial | 2 |
| Applies to | Block containers that establish an inline formatting context |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 25 · Firefox no · Safari 1.3 |
| Spec | css-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.
| Syntax | slice | clone |
|---|---|
| Initial | slice |
| Applies to | All elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 130 · Firefox 32 · Safari no |
| Spec | css-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.
| Syntax | auto | <custom-ident> |
|---|---|
| Initial | auto |
| Applies to | Boxes that create class A break points |
| Inherited | No (but see prose) |
| Animation | Discrete |
| Support | Chrome 85 · Firefox 110 · Safari 1 |
| Spec | css-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; }
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.
| Syntax | auto | always | avoid | left | right | inherit |
|---|---|
| Initial | auto |
| Applies to | Block-level elements (but see text) |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1 · Safari 1.2 |
| Spec | css2 |
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.
| Syntax | avoid | auto | inherit |
|---|---|
| Initial | auto |
| Applies to | Block-level elements (but see text) |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 19 · Safari 1.3 |
| Spec | css2 |