flex-direction
W3C CSS Snapshot 2026
Choose the direction of the main axis. Direction follows the writing mode.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
row | Follows the inline text direction. This is the default. |
row-reverse | Reverses the main axis of row. |
column | Follows the direction blocks stack, usually top to bottom. |
column-reverse | Reverses the main axis of column. |
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-direction 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-direction: row-reverse; gap: 6px; }
</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 A starts at the right in this left-to-right example. Try column to stack the tiles.