Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

flex-wrap — wrapping flex items

The flex-wrap property determines whether a flex container has one line or can create additional lines, and the direction in which those lines stack. Set it on the container, not its items.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

flex-wrap: nowrap | [ wrap | wrap-reverse ] || balance;

flex-wrap applies to containers with display: flex or display: inline-flex. Its initial value is nowrap, and it is not inherited. It controls flex line formation, not text wrapping inside items.

nowrap keeps a single line: items may shrink or overflow the container. wrap allows additional lines. wrap-reverse also allows wrapping but swaps the start and end of the cross axis. It does not reverse item order along the main axis or document order.

Directions depend on flex-direction and writing mode. With row, horizontal-tb, and ltr, additional lines with wrap stack downward; with column, wrapping creates columns and requires constrained space along the main axis. The flex-flow shorthand combines direction and wrapping.

The Level 2 draft adds balance, which balances line lengths. It can accompany wrap or wrap-reverse; alone, it uses the direction of wrap. Do not assume support for this feature in Chromium 152 without separate verification. The example uses wrap and flex: 0 0 100px to disable item shrinking.

Examples

<!doctype html>
<meta charset="utf-8">
<title>flex-wrap</title>
<style>
  .items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 220px;
    gap: 10px;
    direction: ltr;
    writing-mode: horizontal-tb;
  }
  .items > div {
    flex: 0 0 100px;
    height: 40px;
    background: lightblue;
  }
</style>
<div class="items">
  <div>A</div><div>B</div><div>C</div>
</div>

Result

A B
C

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources