← Back to Bootstrap Course | Chapter 1: Getting Started | Lesson 5 of 7

Bootstrap classes overview

Nearly everything in Bootstrap is a class name, from layout and spacing to colours and components.
Syntax
markup
<button class="btn btn-primary">text</button>
<div class="card shadow">...</div>

Bootstrap classes overview

Components use base classes such as .btn, .card and .navbar plus modifiers like .btn-primary. Utilities do one job, for example .mt-3 (margin), .text-center, .d-flex and .bg-dark. Combining a few classes replaces many lines of CSS.

Note: Base class first, then modifiers, then utilities.

Example: Bootstrap classes overview

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">
  <span class="badge text-bg-primary">badge</span>
  <button class="btn btn-outline-danger btn-sm mt-3">btn + modifier + size + utility</button>
  <p class="text-uppercase fw-bold text-secondary mt-3">Utilities: text-uppercase, fw-bold, text-secondary, mt-3</p>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
  1. Using a modifier without its base class
  2. Inventing class names that do not exist
  3. Overriding Bootstrap with inline styles
Chapter Summary
  • Base classes create components
  • Modifiers change variants
  • Utilities do one thing
  • Combine classes to build UIs
🔒

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.