The order
CSS property sets the order to lay out an item in a flex or grid container. Items in a container are sorted by ascending order
value and then by their source code order.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
/* <integer> values */ order: 5; order: -5; /* Global values */ order: inherit; order: initial; order: unset;
Since order
is only meant to affect the visual order of elements and not their logical or tab order. order
must not be used on non-visual media such as speech.
Values
<integer>
- Represents the ordinal group to be used by the item.
Accessibility concerns
Using the order
property will create a disconnect between the visual presentation of content and DOM order. This will adversely affect users experiencing low vision navigating with the aid of assistive technology such as a screen reader. If the visual (css) order is important, then screen reader users will not have access to the correct reading order.
- Flexbox & the keyboard navigation disconnect — Tink
- Source Order Matters | Adrian Roselli
- MDN Understanding WCAG, Guideline 1.3 explanations
- Understanding Success Criterion 1.3.2 | W3C Understanding WCAG 2.0
Formal definition
Initial value | 0
|
Applies to | flex items and absolutely-positioned flex container children |
Inherited | no |
Computed value | as specified |
Animation type | an integer |
Formal syntax
<integer>
Examples
Ordering items in a flex container
This example uses CSS to create a classic two-sidebar layout surrounding a content block. The Flexible Box Layout Module automatically creates blocks of equal vertical size and uses as much horizontal space as available.
HTML
<header>...</header> <main> <article>Article</article> <nav>Nav</nav> <aside>Aside</aside> </main> <footer>...</footer>
CSS
main { display: flex; text-align:center; } main > article { flex:1; order: 2; } main > nav { width: 200px; order: 1; } main > aside { width: 200px; order: 3; }
Result
Specifications
Specification | Status | Comment |
---|---|---|
CSS Flexible Box Layout ModuleThe definition of 'order' in that specification. | Candidate Recommendation | Initial definition |
Initial value | 0
|
Applies to | flex items and absolutely-positioned flex container children |
Inherited | no |
Computed value | as specified |
Animation type | an integer |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
order
|
Chrome Full support 29 Full support 29 Full support 21 Prefixed' Implemented with the vendor prefix: -webkit- |
Edge Full support 12 Full support 12 Full support 12 Prefixed' Implemented with the vendor prefix: -webkit- |
Firefox Full support 20 Full support 20 Notes' Since Firefox 28, multi-line flexbox is supported. Full support 49 Prefixed' Implemented with the vendor prefix: -webkit- Full support 48 Prefixed' Implemented with the vendor prefix: -webkit-
Disabled' From version 48: this feature is behind the Disabled' From version 18 until version 28 (exclusive): this feature is behind the |
IE Full support 11 Full support 11 Full support 10 Prefixed' Implemented with the vendor prefix: -ms- |
Opera
Full support 12.1 |
Safari Full support 9 Full support 9 Full support 7 Prefixed' Implemented with the vendor prefix: -webkit- |
WebView Android Full support 4.4 Full support 4.4 Full support ≤37 Prefixed' Implemented with the vendor prefix: -webkit- |
Chrome Android Full support 29 Full support 29 Full support 25 Prefixed' Implemented with the vendor prefix: -webkit- |
Firefox Android Full support 20 Full support 20 Notes' Since Firefox 28, multi-line flexbox is supported. Full support 49 Prefixed' Implemented with the vendor prefix: -webkit- Full support 48 Prefixed' Implemented with the vendor prefix: -webkit-
Disabled' From version 48: this feature is behind the Disabled' From version 18 until version 28 (exclusive): this feature is behind the |
Opera Android
Full support 12.1 |
Safari iOS Full support 9 Full support 9 Full support 7 Prefixed' Implemented with the vendor prefix: -webkit- |
Samsung Internet Android Full support 2.0 Full support 2.0 Full support 1.5 Prefixed' Implemented with the vendor prefix: -webkit- |
Legend
- Full support
- Full support
- See implementation notes.'
- See implementation notes.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
- CSS Flexbox Guide: Basic Concepts of Flexbox
- CSS Flexbox Guide: Ordering flex items
- CSS Grid Guide: CSS Grid Layout and accessibility
order by Mozilla Contributors is licensed under CC-BY-SA 2.5.