order

Term side of the Card.
Topic: Flexboxes
Unit title: order
Categories: Property
Explanation side of the Card

Explanation: The property used in flexbox layouts to specify the order in which flex items appear in the container. By setting the `order` property, the visual order of items can be changed without altering their source order, allowing for flexible layouts.

Browser compatibility:
  • The chrome browser supports this feature starting from version 29.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 20.
  • The safari browser supports this feature starting from version 9.
Availability: 

Example

Wrongcss
.first {
  order: 1;
}
Rightcss
.first {
  order: -1;
}

All items default to order: 0, so 1 moves an item to the end and -1 moves it to the start.

Common mistakes

  • Keyboard focus jumps around because order changed only the visual layout.

Key points

  • order is not used to fix content order that should change in the HTML, since Tab and screen readers follow the DOM.
  • Items without order are treated as 0, so a value of -1 moves an item first.

Interview questions

Does order work in CSS grid?

Yes. order affects auto-placed items in both flex and grid containers.

Is CSS order bad for accessibility?

It can be. It breaks WCAG meaningful sequence when the visual order differs from the DOM order in a way that changes meaning.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy