The order property lets you change the visual order of flex items without rewriting your HTML. It is a handy tool for responsive layouts and quick rearrangements.
01
Flexbox Order
Rearrange flex items.
02
Integer Values
Positive, negative, zero.
03
Default 0
Source order by default.
04
Visual Only
HTML stays the same.
05
Responsive
Reorder on small screens.
06
Grid Too
Also works in CSS Grid.
Fundamentals
Introduction
The order property in CSS is a part of the Flexible Box Layout Module, commonly known as Flexbox. It allows developers to control the order in which flex items appear within a flex container.
By default, flex items are displayed in the order they appear in the source code. However, the order property enables you to rearrange these items without altering the HTML structure, providing greater flexibility in layout design.
Definition and Usage
Apply order to a flex item (a direct child of a flex container). Lower values appear first; higher values appear later.
Use it for responsive design when you want a sidebar, image, or button to move visually on smaller screens while keeping a logical HTML structure for accessibility.
💡
Beginner Tip
Think of order as a sorting number. -1 moves an item to the front, 0 is default, and 2 pushes an item toward the back.
Foundation
📝 Syntax
The syntax for the order property is simple. It accepts a single integer value, which determines the item’s position among its siblings within the flex container.
syntax.css
.item{order:<integer>;}
<integer> — The value can be positive, negative, or zero. The default value is 0.
Basic Example
order.css
.container{display:flex;}.sidebar{order:-1;}
Syntax Rules
The parent must be a flex container (display: flex or display: inline-flex).
Items are sorted by order value, then by source order for ties.
Negative values move items before those with order: 0.
order also works on grid items inside a grid container.
Defaults
🎯 Default Value
The default value of the order property is 0. All items have the same order value by default, so they are displayed in the order they appear in the HTML source.
You only need to set order on items that should appear out of their normal source position.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
0
Applies to
Flex items and grid items
Inherited
No
Animatable
No
Common use
Responsive reordering in flex and grid layouts
Reference
💎 Property Values
Value
Example
Description
Positive integer
order: 2;
Items with higher positive values appear later in the order
Negative integer
order: -1;
Items with negative values appear earlier in the order
Zero
order: 0;
Default value; item appears in its original source order relative to other zero values
-1 — move to front0 — default1 — move later2+ — move toward back
Preview
👀 Live Preview
HTML order is Item 1, Item 2, Item 3 — but visual order is Item 2, Item 3, Item 1:
Item 1 (order: 2)
Item 2 (order: -1)
Item 3 (order: 0)
Hands-On
Examples Gallery
Reorder flex items with positive, negative, and zero values, then try responsive patterns.
📦 Basic Reordering
Rearrange three items using the reference example values.
Example 1 — Three Items Reordered
In this example, we rearrange the order of three items within a flex container using the order property.
DOM order matters — Screen readers follow HTML source order, not visual order.
Keep focus logical — Tab order follows the DOM, which may not match what users see.
Do not hide important actions — Moving buttons visually can confuse keyboard users if focus jumps unexpectedly.
Prefer semantic HTML first — Reorder in HTML when possible; use order for responsive visual tweaks.
🧠 How order Works
1
Items live in a flex or grid container
The parent uses display: flex or display: grid.
Container
2
Each item gets an order number
Default is 0. Lower numbers appear earlier visually.
Integer
3
Browser sorts by order value
Tied values keep their original source order among each other.
Sort
=
📦
Visual reorder without HTML changes
Layout adapts while the markup structure stays the same.
Compatibility
Browser Compatibility
The order property is widely supported in modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. Test across browsers to ensure consistent behavior.
✓ Baseline · Modern browsers
Strong support in current browsers
order works reliably with flexbox and grid in all up-to-date desktop and mobile browsers.
97%Modern browser support
Google Chrome29+ · Desktop & Mobile
Full support
Mozilla Firefox28+ · Desktop & Mobile
Full support
Apple Safari9+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera17+ · Modern versions
Full support
order property97% supported
Bottom line:order is safe to use with flexbox and grid in modern projects.
Wrap Up
Conclusion
The order property is a powerful feature of Flexbox, enabling developers to control the visual arrangement of elements without modifying the underlying HTML structure.
This property is particularly useful for responsive designs, where the layout needs to adapt to different screen sizes and orientations. By using the order property, you can create more flexible and dynamic layouts for your web projects.