Column ordering lets you change the order of columns on a webpage without changing the HTML. This helps make your layout look good on different screen sizes.
Column ordering in Bootsrap
Use Bootstrap classes like .order-0, .order-1, ..., .order-5 on columns.
You can also use responsive classes like .order-md-1 to change order on medium screens and up.Lower order numbers appear first, higher numbers appear later.
Responsive order classes let you change order at different screen sizes.
<div class="row"> <div class="col order-2">Second column</div> <div class="col order-1">First column</div> <div class="col order-3">Third column</div> </div>
<div class="row"> <div class="col order-md-3">Third on medium+</div> <div class="col order-md-1">First on medium+</div> <div class="col order-md-2">Second on medium+</div> </div>
This example shows three columns with different order classes for medium screens and larger. On small screens, columns appear in HTML order. On medium and larger, columns reorder as 2, 3, 1 visually.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Bootstrap Column Ordering Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <main class="container mt-4"> <h1>Column Ordering Demo</h1> <p>Resize the browser to see column order change on medium screens and up.</p> <div class="row border p-3"> <div class="col bg-primary text-white order-md-3 p-3">Column 1 (order-md-3)</div> <div class="col bg-success text-white order-md-1 p-3">Column 2 (order-md-1)</div> <div class="col bg-warning text-dark order-md-2 p-3">Column 3 (order-md-2)</div> </div> </main> </body> </html>
Order classes only change visual order, not the reading order for screen readers.
Use order classes carefully to keep your page accessible and logical.
Combine with responsive classes to make layouts adapt well on all devices.
Column ordering changes the visual order of columns without changing HTML.
Use Bootstrap's .order-* classes to set order numbers.
Responsive order classes let you reorder columns on different screen sizes.
Practice
.order-* class do in a grid layout?Solution
Step 1: Understand the purpose of
Bootstrap's.order-*classes.order-*classes let you rearrange columns visually without changing their HTML order.Step 2: Compare with other options
The other options describe unrelated styling or behavior, not column ordering.Final Answer:
It changes the visual order of columns without altering the HTML structure. -> Option BQuick Check:
Column ordering = Visual reorder without HTML change [OK]
- Thinking .order-* changes HTML structure
- Confusing order with visibility or color
- Assuming it affects padding or margins
Solution
Step 1: Recall Bootstrap order classes
Bootstrap providesorder-firstto place a column first,order-lastto place last, and numericorder-*from 0 to 12 for custom order.Step 2: Analyze each option
class="col order-1"usesorder-1which is not guaranteed first.class="col order-first"usesorder-firstwhich explicitly places the column first.class="col order-0"usesorder-0which is valid but less clear thanorder-first.class="col order-last"places the column last.Final Answer:
class="col order-first" -> Option DQuick Check:
Use order-first to place column first [OK]
- Using order-0 instead of order-first
- Confusing order-last with order-first
- Using invalid order numbers like order-13
<div class="row"> <div class="col order-3">A</div> <div class="col order-1">B</div> <div class="col order-2">C</div> </div>
What is the visual order of columns on the page?
Solution
Step 1: Understand order numbers
Lower order numbers appear first visually. Here, B has order-1, C order-2, A order-3.Step 2: Arrange columns by order
Order from smallest to largest: B (1), C (2), A (3).Final Answer:
B, C, A -> Option AQuick Check:
Order numbers ascending = B, C, A [OK]
- Assuming HTML order is visual order
- Mixing up order numbers and column content
- Ignoring that order-1 is before order-2
Solution
Step 1: Understand responsive order classes
Bootstrap uses breakpoint prefixes likesm,md,lgto apply order changes at specific screen sizes.Step 2: Match requirement to class
To reorder only on small screens, useorder-sm-first.order-firstapplies to all sizes.order-lg-firstapplies on large screens.order-lastplaces last always.Final Answer:
order-sm-first -> Option CQuick Check:
Use order-sm-first for small screen reorder [OK]
- Using order-first which affects all sizes
- Using order-lg-first which affects large screens
- Confusing order-last with order-first
<div class="col order-2 order-md-1">First</div> <div class="col order-1 order-md-2">Second</div> <div class="col order-3">Third</div>
How will the columns appear on small and medium screens respectively?
Solution
Step 1: Analyze small screen order
On small screens,order-*without breakpoint applies. So orders are: First=2, Second=1, Third=3. Visual order: Second (1), First (2), Third (3).Step 2: Analyze medium screen order
On medium screens,order-md-*overrides. First=1, Second=2, Third=3. Visual order: First, Second, Third.Final Answer:
Small: Second, First, Third; Medium: First, Second, Third -> Option AQuick Check:
Breakpoint order overrides default order [OK]
- Ignoring breakpoint-specific order classes
- Assuming order-md-* applies on small screens
- Mixing up order numbers and visual positions
Ready to prove it?
Pass the test and this pattern moves unknown
