Skip to content

Bootstrap Basics

Before building full layouts, you need to understand the small set of ideas that power every Bootstrap page: containers, rows, columns, and utility classes.

Bootstrap Basics Overview

Every Bootstrap layout follows the same pattern: a container establishes horizontal padding and a max width, a row creates a flex context, and columns divide the row into a 12-part grid. Utility classes then adjust spacing, color, and typography without custom CSS.

Bootstrap also resets default browser styling through Reboot, its lightweight CSS normalization layer, so headings, forms, and tables look consistent across browsers before you apply a single class.

Concept Description Common Usage
Reboot Cross-browser CSS reset baked into Bootstrap Consistent default margins, fonts, and box-sizing
Container Fixed or fluid wrapper with responsive padding Centering and constraining page content
Row / Column Flexbox-based 12-column grid Arranging content into responsive layouts
Utility Classes Single-purpose helper classes Spacing, color, display, and text adjustments
Breakpoints Named screen-width thresholds (sm, md, lg, xl, xxl) Changing layout per device size

Bootstrap Basics Example

<div class="container">
  <div class="row">
    <div class="col-sm-6">
      <h2 class="h4">Left column</h2>
      <p class="text-secondary">Basic Bootstrap text utilities.</p>
    </div>
    <div class="col-sm-6">
      <h2 class="h4">Right column</h2>
      <p class="text-secondary">Columns stack on mobile, sit side by side on larger screens.</p>
    </div>
  </div>
</div>

The container centers the page content, the row creates the grid context, and the two col-sm-6 columns split the row evenly once the viewport reaches the sm breakpoint, stacking full width below it.

Top 10 Bootstrap Basics Examples

These are the fundamental class patterns that appear on almost every page built with Bootstrap.

# Example Syntax
1 Fixed container <div class="container">...</div>
2 Fluid container <div class="container-fluid">...</div>
3 Equal-width columns <div class="row"><div class="col">A</div><div class="col">B</div></div>
4 Heading utility <h2 class="h4">Smaller heading</h2>
5 Text color <p class="text-secondary">Muted text</p>
6 Background color <div class="bg-light p-3">Light background</div>
7 Border utility <div class="border rounded p-2">Bordered box</div>
8 Display utility <span class="d-none d-md-inline">Visible on md+</span>
9 Float/clearfix helper <div class="clearfix">...</div>
10 Vertical alignment <div class="d-flex align-items-center">...</div>

Best Practices

  • Always nest columns inside a row, and rows inside a container or container-fluid.
  • Prefer col (equal width) over manually calculated column sizes when columns should share space evenly.
  • Use semantic HTML elements first, then layer Bootstrap classes on top.
  • Learn the breakpoint abbreviations (sm, md, lg, xl, xxl) since they appear in almost every class.
  • Use text and background utility classes instead of writing new CSS rules for common colors.
  • Group related utilities logically in the class attribute so markup stays readable.
  • Test basic layouts at multiple screen widths before adding more complexity.

Common Mistakes

  • Placing columns directly inside a container without a row wrapper.
  • Using fixed pixel widths instead of Bootstrap's column and breakpoint system.
  • Forgetting that .container has a max-width and won't stretch edge to edge.
  • Overriding Reboot's default styles unintentionally with global CSS resets.
  • Nesting too many rows and columns for a layout that could be simpler.
  • Not checking how utilities like d-none behave across different breakpoints.

Key Takeaways

  • Container, row, and column are the three building blocks of every Bootstrap layout.
  • Reboot normalizes default browser styling before you add any classes.
  • Utility classes handle spacing, color, and display without custom CSS.
  • Breakpoint abbreviations (sm, md, lg, xl, xxl) control responsive behavior.
  • Mastering these basics makes every later Bootstrap topic easier to learn.

Pro Tip

Open your browser's dev tools and toggle device widths while experimenting with col-* and d-* classes; seeing the grid respond live builds intuition faster than reading docs alone.