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

Nesting

You can place a new row of columns inside a column to build more complex layouts.

In this page:

  1. Nesting
Syntax
markup
<div class="row">
  <div class="col-8">
    <div class="row">
      <div class="col-6">nested</div>
      <div class="col-6">nested</div>
    </div>
  </div>
</div>

Nesting

Inside a column, add a new .row with its own columns. The nested row again divides its parent column into twelve parts, so widths are relative to the parent. Nesting is handy for sub-layouts such as cards in a sidebar.

Note: Nested rows do not need a container.

Example: Nesting

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">
  <div class="row">
    <div class="col-sm-8 bg-light border p-2">
      Level 1: col-sm-8
      <div class="row mt-2">
        <div class="col-6 bg-primary text-white p-2">Level 2: col-6</div>
        <div class="col-6 bg-secondary text-white p-2">Level 2: col-6</div>
      </div>
    </div>
    <div class="col-sm-4 bg-light border p-2">Level 1: col-sm-4</div>
  </div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
  1. Adding a container inside a column
  2. Expecting nested widths to relate to the page
  3. Nesting too deeply
Chapter Summary
  • Put a row inside a col
  • The nested grid has its own 12 columns
  • No container needed
  • Widths are relative to the parent column
🔒

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.