Auto-Layout Columns & Variable Width

Bootstrap Framework 8 min min read Updated: Nov 16, 2026 Beginner
Auto-Layout Columns & Variable Width
Beginner Topic 3 of 7

Equal-Width Columns

You do not have to set numbers every time. If you only write col, Bootstrap divides the space equally between all the columns in that row.

html <div class="row"> <div class="col">1 of 2</div> <div class="col">2 of 2</div> </div> <div class="row"> <div class="col">1 of 3</div> <div class="col">2 of 3</div> <div class="col">3 of 3</div> </div>
Result

The first row has two halves. The second row has three equal thirds.

Setting the Width of One Column

If you give one column a number, the other columns share the remaining space equally.

html <div class="row"> <div class="col">Auto</div> <div class="col-6">Takes 6 of 12 parts</div> <div class="col">Auto</div> </div>

Here the middle column takes half the row. The two col columns share the remaining half, so each gets 3 parts.

Variable Width Content: col-auto

col-auto makes the column only as wide as its content. The other col columns use the rest of the space.

html <div class="row"> <div class="col">Fills the extra space</div> <div class="col-auto">Only as wide as I am</div> <div class="col">Fills the extra space</div> </div>

Real Example: Search Bar

html <div class="row"> <div class="col"> <input type="text" class="form-control" placeholder="Search..."> </div> <div class="col-auto"> <button class="btn btn-primary">Search</button> </div> </div>
Result

A long input field with a small button right next to it. The button stays small and the input takes all remaining space.

Responsive Equal Width

You can also use col-sm, col-md and others without a number. Columns are stacked below that breakpoint and become equal width above it.

html <div class="row"> <div class="col-md">First</div> <div class="col-md">Second</div> <div class="col-md">Third</div> </div>

Summary of Column Types

ClassBehavior
colEqual share of the remaining space
col-6Exactly 6 of 12 parts
col-autoWidth of its content
col-mdEqual width from md up, stacked below
col-md-autoWidth of content from md up, stacked below
Tip: Use col-auto for buttons, icons and labels, and col for flexible areas such as inputs and text blocks.

Conclusion

Auto layout saves you from doing the math. Use col when you want equal widths and col-auto when the content should decide the width.

Quick Summary: col shares space equally, col-6 fixes a width, col-auto uses content width, and col-md makes it responsive.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators