There comes a point in every frontend project where you want to show elements in a different order than they appear in your HTML. Maybe you want the sidebar on the left for desktop but below the main content on mobile. Maybe a design change means the call-to-action button needs to appear above the description instead of below it.
You could restructure the HTML. But that creates maintenance headaches, especially when the visual order differs across breakpoints. The CSS Flexbox order property solves this cleanly. It lets you rearrange flex items visually while keeping your markup logical and accessible.
This is not some obscure trick. The order property has been part of the Flexbox specification from the start, and it has full browser support across everything that matters in 2026. Yet many developers overlook it because they learned Flexbox through justify-content and align-items tutorials that never covered reordering.
How the Order Property Works
Every flex item has a default order value of 0. Items with the same order value appear in the order they show up in the HTML source. When you assign a different order value, items with lower numbers come first, and items with higher numbers come last.
`css
.container {
display: flex;
}
.sidebar { order: 2; }
.main-content { order: 1; }
.header {
order: 0;
}
`
In this example, the header appears first (order 0), then the main content (order 1), then the sidebar (order 2). This happens regardless of where these elements sit in your HTML.
Negative values work too. If you want an element to appear before everything else without changing the order values of other items, give it order: -1. This is handy when adding a new element that needs to appear first without renumbering everything.
The Flexbox Playground lets you drag items around and see how changing order values affects the layout. It is much faster than writing CSS by hand when you are figuring out the right arrangement.

Responsive Reordering with Media Queries
The real power of order shows up in responsive design. You can rearrange your layout at different breakpoints without duplicating HTML or using JavaScript:
`css
.card-image {
order: 1;
}
.card-text { order: 2; }
@media (max-width: 768px) {
.card-image {
order: 2;
}
.card-text {
order: 1;
}
}
`
On desktop, the image comes first. On mobile, the text comes first so users see the headline before scrolling to the image. The HTML stays the same, and screen readers still read it in the original source order.
This pattern works well for product pages, blog layouts, and dashboards where the information hierarchy changes between large and small screens. Pair it with flex-direction: column on mobile to stack elements vertically while reordering them.
One thing to watch: do not use order to fix a broken HTML structure. If your content makes no logical sense in source order, fix the HTML. The order property is for visual adjustments, not for working around bad markup.
The real power of `order` shows up in responsive design.
Accessibility Considerations When Reordering
Screen readers and keyboard navigation follow the DOM order, not the visual order. This means that if you use order to put a button visually at the top of the page but it sits at the bottom of the HTML, a keyboard user will tab through everything else before reaching that button.
This disconnect between visual and tab order is the biggest accessibility concern with the order property. The W3C specifically warns about it in the Flexbox specification.
Practical guidelines to keep things accessible:
- Keep the source order logical. A user reading the HTML without any CSS should still understand the content flow.
- Test with keyboard navigation. Tab through your page after reordering and check if the focus sequence makes sense.
- Use
orderfor minor visual tweaks, not for wholesale rearrangement. If you are reordering 5 or more items, consider restructuring the HTML instead. - When reordering form elements, be especially careful. Form fields that appear in a different order visually than their tab order will confuse users.
The rule of thumb: if a sighted keyboard user would be confused by the tab order not matching what they see on screen, you have gone too far with visual reordering.
Order vs. Grid Placement vs. Flex Direction
CSS gives you multiple ways to control element order. Each has its use case:
order property: best for minor reordering within a flex container. Simple to use, works with media queries, but affects only visual order within that specific container.
flex-direction: row-reverse or column-reverse: reverses the entire flow of items. Useful when you want everything in the opposite order, but too blunt when you only want to move one item.
CSS Grid placement: gives you explicit row/column positions. More powerful than order because you can place items in any cell of a two-dimensional grid. Use this when you need precise control over both rows and columns.
`css
/ Grid placement example /
.sidebar {
grid-column: 1;
grid-row: 1 / 3;
}
.main {
grid-column: 2;
}
`
The Grid Calculator helps you visualize grid placement, which is useful when deciding between order and grid-based positioning. For one-dimensional reordering, order is simpler. For two-dimensional layouts, Grid placement gives you more control.

Common Patterns Using the Order Property
Mobile-first navigation: put the nav at the bottom of your HTML (after the main content for SEO) but display it at the top visually with order: -1.
Alternating card layouts: in a card grid, alternate image-left/image-right patterns by giving even cards order: 1 on the image and order: 2 on the text, then reversing on odd cards.
Priority content on mobile: on a dashboard with multiple widgets, move the most important widget to order: -1 on mobile so it appears first, even if it sits in the middle of the desktop layout.
Form field reordering: move the submit button above optional fields on mobile to reduce scrolling. This works as long as the required fields are filled in before the button in tab order.
Footer to header: move a sticky footer element (like a cookie banner) to appear at the top on specific breakpoints by changing its order value in a media query.
After building your layout, run the CSS through a CSS Minifier to strip out the whitespace and comments. Order property declarations are small, but every byte counts when your stylesheet has dozens of responsive breakpoints.
FAQ
Does the order property work with CSS Grid?
Yes. The order property works on both flex items and grid items. For grid, it controls the auto-placement order when items do not have explicit row/column positions. However, explicit grid placement (using grid-column and grid-row) overrides the order property, so it is most useful with Grid when items are auto-placed.
Can I animate the order property?
No. The order property is not animatable because it changes the layout position of elements, not a numeric visual property like opacity or transform. If you need animated reordering, use transform: translateX() or a JavaScript animation library instead.
Does order affect SEO?
No. Search engines read the DOM order, not the visual order. This is actually an advantage: you can structure your HTML for optimal SEO (important content first) while arranging the visual layout differently for design purposes.
What happens when two items have the same order value?
They appear in their source order. The order property only overrides the default when values differ. If three items all have order: 1, they render in the same order as they appear in the HTML.
### Does the order property work with CSS Grid.
Markdown Table Generator: Build Clean Tables Without the Pain
Markdown tables are simple until the pipes and dashes stop lining up. Learn the syntax, alignment tricks, and a free tool that formats tables for you.
CSV to JSON: Convert Spreadsheet Data for APIs and Code
Turn a CSV export into clean JSON for APIs, imports, and scripts. Learn how the conversion works, common pitfalls with types and quotes, and a free tool.
JSON Guide: Format, Validate, and Convert JSON Files
JSON guide for developers: syntax rules, common parse errors, formatting and schema validation, plus how to convert between JSON and CSV files.
