← Back to Bootstrap Course | Chapter 2: Grid System | Lesson 2 of 7

12-column grid

Each row is divided into twelve equal parts, and columns claim some of those parts.

In this page:

  1. 12-column grid
Syntax
markup
<div class="row">
  <div class="col-4">one third</div>
  <div class="col-8">two thirds</div>
</div>

12-column grid

A class like col-4 takes four of twelve columns (one third). Columns in a row that add up to more than twelve wrap onto a new line. Combining widths such as 8 and 4, or 3 three times and 3 again, lets you build any layout.

Note: 12 divides evenly by 2, 3, 4 and 6, which is why it is used.

Example: 12-column grid

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container text-center">
  <div class="row mb-2"><div class="col-8 bg-primary text-white">col-8</div><div class="col-4 bg-secondary text-white">col-4</div></div>
  <div class="row mb-2"><div class="col-3 bg-info">3</div><div class="col-3 bg-info">3</div><div class="col-3 bg-info">3</div><div class="col-3 bg-info">3</div></div>
  <div class="row"><div class="col-6 bg-success text-white">6</div><div class="col-6 bg-success text-white">6</div><div class="col-6 bg-danger text-white">wraps (6+6+6 > 12)</div></div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
  1. Making widths add up to more than 12 by accident
  2. Expecting unequal widths without classes
  3. Forgetting columns wrap
Chapter Summary
  • Twelve columns per row
  • col-N takes N of 12
  • Extra columns wrap
  • 12 splits into halves, thirds, quarters
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.