order
Quick Summary for order
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.
Code Usage for order
/* <integer> values */ order: 5; order: -5;  /* Global values */ order: inherit; order: initial; order: revert; order: unset; 
More Details for order

order

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.

Syntax

/* <integer> values */ order: 5; order: -5;  /* Global values */ order: inherit; order: initial; order: revert; 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 value0
Applies toFlex items, grid items, and absolutely-positioned flex and grid container children
Inheritedno
Computed valueas specified
Animation typean 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
CSS Display Module Level 3 # order-property

See also

CSS Flexbox Guide: Basic Concepts of Flexbox CSS Flexbox Guide: Ordering flex items CSS Grid Guide: CSS Grid Layout and accessibility

Last modified: Aug 12, 2021, by MDN contributors

Select your preferred language English (US)DeutschEspañolFrançais日本語한국어Русский中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
The problem with hoarding is you end up living off your reserves. Eventually, you’ll become stale. If you give away everything you have, you are left with nothing. This forces you to look, to be aware, to replenish. . . . Somehow the more you give away, the more comes back to you.
Paul Arden
Random CSS Property

border-block-color

The border-block-color CSS property defines the color of the logical block borders of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation. It corresponds to the border-top-color and border-bottom-color, or border-right-color and border-left-color property depending on the values defined for writing-mode, direction, and text-orientation.
border-block-color css reference