order

W3C CSS Snapshot 2026

Change the order the grid uses for automatic placement. Keep the source order logical for reading and keyboard navigation.

On this page

Syntax and values

Value or syntaxWhat it does
0The default order group. Items with the same value keep their source order.
-1 / 1Negative values move before the default group and positive values after it for automatic placement.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>order 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 { grid-template-columns: 1fr 1fr; grid-template-rows: 60px 60px; }
.layout .second { order: -1; }
  </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 B is placed in the first cell, then A and C.

Official references