order Property in Flexbox – How to Reposition Flex Item
order changes a flexible item’s default order (arrangement).
In other words, order
allows you to reposition a flexbox’s item without altering your HTML code’s layout.
Here’s an example:
The HTML snippet above used the order
property to change the unordered list’s arrangement.
So, instead of the following order:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
The browser will display this:
- 3
- 5
- 7
- 2
- 6
- 1
- 4
Use the order
property with caution, as it prevents screen readers from accessing the correct reading order of an HTML document. Only use it if it is super important to use CSS to change the HTML code’s layout.
But in most cases, it is best to rearrange the HTML code directly rather than using CSS.