CSS order Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The order property sets how a flex or grid item is sorted in the visual layout. Items are laid out by ascending order value. When values match, HTML source order decides the tie.

Set it on the item, not the container. The default is 0. It does not change the DOM, tab order, or what screen readers announce — only how boxes are painted.

Baseline · Widely available.

Not deprecated and not experimental. Use it for visual tweaks only. Do not use order to fix a wrong logical reading or focus order — change the HTML instead.

CSS Syntax

syntax.css
order: <integer> | initial | inherit;

Example: order: -1; places that item before siblings still at 0.

Property Values

ValueDescriptionTry it
<integer>Ordinal group. Lower values come first. Default is 0Try it
NegativeValues below 0 appear before default itemsTry it
Same valueTied items keep HTML source order within that groupTry it
initialSets this property to its default value, 0Try it
inheritInherits this property from the parent elementTry it

How to Use order

Make a flex or grid container, then assign integers to the items you want to move visually.

  1. Set display: flex or display: grid on the parent.
  2. Leave most items at the default 0.
  3. Give earlier items a lower integer (often negative). Give later items a higher integer.
  4. Check keyboard and screen-reader flow still make sense with the HTML source.
PieceRequired?Role
Flex or grid containerYesWithout it, order does nothing
Integer on the itemYesSets which ordinal group the item belongs to
Source orderTie-breakerUsed when two items share the same order
Accessible HTML orderYes for UXTab and speech still follow the markup

Live Preview

Three items in source order A, B, C. Change order on A and watch where it moves. B and C stay at 0.

HTML source is still A then B then C. Only the painted order changes.

Items
A
B
C

A has order: 0 — source order A, B, C

CSS Examples

Each snippet uses only what order needs: a flex container and integer values on items. Use Try It Yourself for a live editor.

Example 1 — Reorder Flex Items

Move the second item first with a negative value, and push the first item later.

CSS
<style>
  section {
    display: flex;
  }
  .a { order: 2; }
  .b { order: -1; }
  .c { order: 0; }
</style>

<section>
  <div class="a">A</div>
  <div class="b">B</div>
  <div class="c">C</div>
</section>
Try It Yourself

How It Works

  1. Make a flex row. display: flex turns the children into flex items.
  2. Sort by number. B at -1 is lowest, so it paints first.
  3. Default group next. C stays at 0, so it comes after B.
  4. Highest last. A at 2 is last. Visual order is B, C, A — source is still A, B, C.

Example 2 — Same Order Value

When two items share an order, source order breaks the tie.

CSS
<style>
  section {
    display: flex;
  }
  .first { order: 1; }
  .mid { order: 2; }
  .last { order: 2; }
</style>

<section>
  <div class="first">First</div>
  <div class="mid">Mid</div>
  <div class="last">Last</div>
</section>
Try It Yourself

How It Works

  1. Group by integer. First is alone in group 1.
  2. Shared group 2. Mid and Last both use order: 2.
  3. Source decides the tie. Mid appears before Last in HTML, so Mid paints before Last.
  4. Visual result: First, Mid, Last — same as source here, but the rule still matters when you reshuffle markup.

Example 3 — Sidebar Layout

Keep article first in HTML for reading order, but show nav, article, aside visually.

CSS
<style>
  main {
    display: flex;
  }
  article { order: 2; flex: 1; }
  nav { order: 1; width: 100px; }
  aside { order: 3; width: 100px; }
</style>

<main>
  <article>Article</article>
  <nav>Nav</nav>
  <aside>Aside</aside>
</main>
Try It Yourself

How It Works

  1. Source puts article first so readers and screen readers meet the main content early.
  2. Nav gets order: 1 so it paints on the left.
  3. Article gets order: 2 and flex: 1 to fill the middle.
  4. Aside gets order: 3 for the right column. Tab order still follows article → nav → aside in the HTML.

Edge Cases & Pitfalls

If items do not move, or focus jumps oddly, check these first.

a11y

Visual order ≠ DOM / tab order

Screen readers and Tab still follow HTML. Prefer a sensible source order over heavy order tricks. See also tabindex.

parent

Needs a flex or grid parent

On a normal block child, order is ignored. Set display: flex or grid on the container.

item

Set on the item, not the container

order is not inherited. Putting it only on the flex container does not reorder the children.

reverse

flex-direction: *-reverse is different

row-reverse flips the whole line. order moves individual items. Both are visual-only for accessibility.

speech

Not for non-visual media

The property is meant for visual layout only. Do not rely on it to reorder content for speech or other non-visual presentations.

Browser Support

order is a browser layout property for flex and grid items. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

order

Flex: Chrome 29+, Firefox 20+, Safari 9+, Edge 12+, IE 10+. Grid support follows modern grid (Chrome 57+, Firefox 52+, Safari 10.1+).

97% Flex item support
Google Chrome 29+ flex · 57+ grid
Full support
Mozilla Firefox 20+ flex · 52+ grid
Full support
Apple Safari 9+ flex · 10.1+ grid
Full support
Microsoft Edge 12+ flex · 16+ grid
Full support
Opera 12.1+ flex · grid in Chromium 57+
Full support
Samsung Internet Supported
Full support
Internet Explorer 10–11 · Flex (old)
Partial
order Widely supported

Bottom line: Safe for flex and grid in current browsers. Prefer sensible HTML source order for accessibility. This is not a JavaScript runtime API.

Key Takeaways

  • Role: sort flex or grid items by ascending integer for visual layout only.
  • Initial: 0. Not inherited. Ties use source order.
  • Negative first: -1 appears before siblings still at 0.
  • Accessibility: fix the HTML when logical order must match what people see.

One line: order paints items by number — it does not rewrite the document’s reading or focus order.

Frequently Asked Questions

It sets the visual layout order of a flex or grid item. Items are sorted by ascending order value, then by HTML source order. It does not change the DOM, tab order, or screen-reader order.
The initial value is 0. Items with the same order value keep their source order relative to each other.
It applies to flex items and grid items. On a child whose parent is not a flex or grid container, order has no effect.
Yes. Lower values come first. A negative value such as -1 appears before items still at the default 0.
No. Tab order and assistive technology follow the HTML source. Prefer fixing the source order when the logical reading order must match what users see.
It is Baseline Widely available. Flex support includes Chrome 29+, Firefox 20+, Safari 9+, Edge 12+, and IE 10+. It is a browser layout property, not a Node.js feature.

Next: orphans

Control the minimum lines left at the bottom of a page or column.

orphans tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful