display
W3C CSS Snapshot 2026
Create a grid container. Its direct children become grid items.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
grid / block grid | Creates a block-level grid container. |
inline-grid / inline grid | Creates a grid container that sits inline with surrounding content. |
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: grid; 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-grid; width: auto; grid-template-columns: repeat(3, auto); }
</style>
</head>
<body>
<div class="layout">
<div class="first">A</div>
<div class="second">B</div>
<div>C</div>
</div>
<span>After the grid</span>
</body>
</html>
What to expect The grid and the text after it share one line. Change to grid to see the text move below.