flex-wrap
W3C CSS Snapshot 2026
Allow the container to start new flex lines when items do not fit.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
nowrap | Uses a single flex line. This is the default. |
wrap | Allows new lines in the normal cross-axis direction. |
wrap-reverse | Wraps with the cross-start and cross-end sides swapped. |
Try the example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>flex-wrap example</title>
<style>
.layout { display: flex; width: min(100%, 320px); border: 2px solid teal; box-sizing: border-box; }
.layout > div { padding: 8px 12px; background: #def5f5; color: #123; border: 1px solid #81b9b5; box-sizing: border-box; }
.layout { flex-wrap: wrap; gap: 6px; }
.layout > div { flex: 0 0 42%; }
</style>
</head>
<body>
<div class="layout">
<div class="first">A</div>
<div class="second">B</div>
<div>C</div>
</div>
</body>
</html>
What to expect C moves to a second line. Change wrap to nowrap to keep all items on one line.