order

W3C CSS Snapshot 2026

Change the visual arrangement of an item. Keep the HTML order meaningful for keyboard and screen reader users.

On this page

Syntax and values

Value or syntaxWhat it does
0All items start in this order group. Ties use the source order.
-1Places the item before the default group in visual order.
1 / 2Places the item after the default group. Integers are sorted from low to high.

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: 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 { gap: 6px; }
.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 appears before A. Change -1 to 1 to place B at the end.

Official references