display

W3C CSS Snapshot 2026

Create the flex container on the parent. Its direct children become flex items.

On this page

Syntax and values

Value or syntaxWhat it does
flex / block flexCreates a block-level flex container.
inline-flex / inline flexCreates a flex container that fits into the surrounding line.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>display 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 { display: inline-flex; width: auto; }
  </style>
</head>
<body>
<div class="layout">
  <div class="first">A</div>
  <div class="second">B</div>
  <div>C</div>
</div>
<span>After the container</span>
</body>
</html>

What to expect A, B, and C share the line with the words after the flex container. Change to flex to see the words start below.

Official references