Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. order

order

Specifies the visual display order of flex items. You can change the visual order without altering the DOM order.

Sample Code

/* Initial value (follows DOM order) */
.item { order: 0;}

/* Move to the front */
.item-first { order: -1;}

/* Move to the end */
.item-last { order: 1;}

/* Specify arbitrary order */
.item-a { order: 3;}
.item-b { order: 1;}
.item-c { order: 2;}

Available Values

ValueDescription
<integer>An integer value. The initial value is '0'. Negative values are allowed. Items with smaller values are placed earlier.

Specification

ItemDetails
Initial value0
Applies toFlex items
InheritedNo
AnimationYes (interpolated as integer)

Browser Compatibility

Chrome Chrome
29+
28
27
26
25
24
23
22
21
↑ Requires prefix '-webkit-'
20 and earlier ×
Firefox Firefox
20+
19 and earlier ×
Safari Safari
9+
8
7
↑ Requires prefix '-webkit-'
6 and earlier ×
Edge Edge
12+
Supported in all versions
IE IE
11
10
Requires prefix '-ms-'
9 ×
8 ×
7 ×
6 ×
Opera Opera
12.1+
11 and earlier ×
iOS Safari iOS Safari
9+
8
7
↑ Requires prefix '-webkit-'
6 and earlier ×
Android Android Browser
4.4+
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop
Firefox Android Firefox Android
Latest
Same support as desktop

※ Version data is based on MDN / Can I Use.

Details

'order' is a property applied to flex items that changes only the visual display order without altering the DOM order. All items have an initial value of '0'. Items with smaller values are placed earlier, and items with larger values are placed later. Items with the same value follow their DOM order.

Ordering Rules

DOM order (order in HTML) A (order:2) B (order:-1) C (order:0) D (order:2) After applying order Display order (actual arrangement) B (-1) C (0) A (2) D (2)

Items are arranged from smallest to largest 'order' value. Items with the same value are arranged according to their DOM order.

/* DOM order: A → B → C → D */
.item-a { order: 2;}   /* 3rd */
.item-b { order: -1;}  /* 1st (smallest value) */
.item-c { order: 0;}   /* 2nd */
.item-d { order: 2;}   /* 4th (same value as A but comes after A in DOM) */
/* Display order: B → C → A → D */

Pattern 1: Reordering for Responsive Layouts

PC — Horizontal (follows DOM order) Sidebar Main Content SP — Vertical (main content moved to top) Main Content (order: -1) Sidebar

/* Normal order on PC, main content first on SP */
.sidebar { order: 0;}
.main-content { order: 0;}

@media (max-width: 768px) {
    .main-content { order: -1;}  /* Move main to the top */
}

Pattern 2: Moving a Specific Item to the End

/* Always place the "Load More" button at the end */
.card { order: 0;}
.more-button { order: 999;}

Accessibility Note

'order' only changes the visual display order via CSS — the HTML DOM order remains unchanged. Screen readers and keyboard Tab navigation follow the DOM order, so the visual order and the interaction order may differ.

For purely decorative reordering this is generally not a problem, but when reordering interactive elements such as navigation or forms, it is preferable to change the order in the HTML itself wherever possible.

Difference from 'flex-direction: reverse'

To reverse the entire order, use 'flex-direction: row-reverse' or 'column-reverse'. Use 'order' when you want to change the order of individual items independently.

Related Properties

PropertyDescription
flex-directionSpecifies the direction items are placed. Use 'row-reverse' or 'column-reverse' to reverse the entire order.

If you find any errors or copyright issues, please .