CSS

🎯 CSS order Property

The order CSS property in Flexbox defines the visual order of items inside a flex container.

It allows you to rearrange elements without changing the HTML structure.

  • 📌 Important Note

  • Smaller values appear first, larger values appear later.
  • Negative values are also allowed.

🔹 order Values

1️⃣ number

You can assign a numeric value (positive or negative). Lower numbers appear first.

CSS

.item1 { order: 2; }
.item2 { order: 1; }
.item3 { order: 3; }
                

Result order: item2 → item1 → item3

2️⃣ initial

Resets the property to its default value (usually 0).

🧩 Example Usage

CSS

.container {
    display: flex;
}

.item1 { order: 3; }
.item2 { order: 1; }
.item3 { order: 2; }
                

The visual order becomes: item2 → item3 → item1, regardless of HTML order.

  • ✔️ Quick Summary

  • number → Controls visual order (lower first)
  • initial → Resets to default (0)