order

Changing the visual order of flex items without changing the HTML.

Time to read: less than 5 min

Briefly

With the order property, you can change the display order of flex items inside a flex container.

Example

In this example, the element with the class .item will be last, even if it is first in the markup.

        
          
          .container {  display: flex;}.item {  order: 3;}
          .container {
  display: flex;
}

.item {
  order: 3;
}

        
        
          
        
      

How to understand

By default, elements are displayed in the order they appear in the markup, and the value of the order property is 0. But this property allows rearranging them.

How it’s written

The value is set as a whole negative or positive number. Elements will appear in ascending order.

Example of flex items order property

Tips

💡 The property only changes the visual order. It's important to remember this. Screen readers will still read elements in the order they appear in the markup.

Поддержка в браузерах:
  • Chrome 29, поддерживается
  • Edge 12, поддерживается
  • Firefox 28, поддерживается
  • Safari 9, поддерживается
О Baseline