Getting Started with Bootstrap
Learn the three ways to add Bootstrap to your project — CDN, download, and npm. Understand the required page structure, containers, the 12-column grid, utility classes, and how to build your first complete Bootstrap page.
- Requirements
- 3 Setup Methods
- CDN Method
- Download Method
- NPM Method
- Page Structure
- Containers
- Grid System
- Utility Classes
- Full Example
- Common Mistakes
- Try It
- FAQ
Requirements Before You Start
Bootstrap is built on top of HTML and CSS. Before starting, you should have a basic understanding of these three technologies. You don't need to be an expert — but knowing what a tag, property, and class selector are will make Bootstrap much easier to follow.
3 Ways to Add Bootstrap
There are three methods to include Bootstrap in your project. Choose based on your experience and project type:
No download needed. Add two lines of code. Works immediately. Ideal for learning and small projects.
Download Bootstrap files and link them locally. Works offline. Good for medium projects.
Package manager install. For professional projects using Webpack, Vite, React, or Vue.
Method 1 — Bootstrap via CDN
The CDN method is the fastest way to start using Bootstrap. No download, no installation — just add two lines of code to your HTML file and Bootstrap is ready. TipsInLearning recommends this method for all beginners.
Step 1 — Add Bootstrap CSS in <head>
Paste this <link> tag inside your <head> section, after the viewport meta tag:
<!-- Bootstrap 5 CSS — paste inside <head> --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" >
Step 2 — Add Bootstrap JS before </body>
Paste this <script> tag just before the closing </body> tag. The JS bundle includes Popper.js (needed for dropdowns and tooltips):
<!-- Bootstrap 5 JS Bundle (includes Popper) — paste before </body> --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous" ></script>
Instant Setup
Zero download, zero installation — Bootstrap is live in under 60 seconds.
Fast Loading
CDN servers worldwide cache the files — often loads faster than local hosting.
Always Updated
Pin to a specific version (like 5.3.2) to control exactly which Bootstrap you use.
Integrity Check
The integrity attribute verifies the file hasn't been tampered with.
Method 2 — Download Bootstrap Files
Download Bootstrap files to your computer and link them from your project folder. This method works offline and gives you full control over the files. Useful for production projects where you can't rely on external CDN availability.
How to download
- Go to getbootstrap.com and click the "Download" button
- Download the "Compiled CSS and JS" ZIP file
- Extract the ZIP — you'll get a css/ and js/ folder
- Copy those folders into your project directory
- Link the files in your HTML as shown below
<!-- CSS in <head> --> <link rel="stylesheet" href="css/bootstrap.min.css"> <!-- JS before </body> --> <script src="js/bootstrap.bundle.min.js"></script>
Recommended folder structure
my-project/ ├── css/ │ └── bootstrap.min.css ├── js/ │ └── bootstrap.bundle.min.js ├── index.html └── style.css ← your custom CSS file
Method 3 — NPM / Yarn (Advanced)
For professional developers using build tools like Webpack or Vite, or frameworks like React, Vue, or Angular, install Bootstrap via npm or Yarn. This method gives you full control over which Bootstrap components to import and enables tree-shaking to reduce file size.
npm install bootstrap@5.3.2
yarn add bootstrap@5.3.2
Then import Bootstrap in your main JavaScript or SCSS entry file:
// Import Bootstrap CSS import 'bootstrap/dist/css/bootstrap.min.css'; // Import Bootstrap JS (all components) import 'bootstrap'; // Or import only what you need (tree-shaking) import { Modal, Dropdown, Tooltip } from 'bootstrap';
Bootstrap Page Structure
Every Bootstrap page needs a specific skeleton. The order matters — especially the viewport meta tag and where the JS goes. Here is the correct structure for a complete Bootstrap 5 HTML page:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- Required: tells mobile browsers how to scale the page --> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>My Bootstrap Page</title> <!-- Bootstrap CSS (must come before your own CSS) --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- Your own CSS comes after Bootstrap --> <link rel="stylesheet" href="style.css"> </head> <body> <!-- All your page content goes here --> <div class="container"> <h1>Hello, TipsInLearning Bootstrap!</h1> <p class="lead">This is my first Bootstrap 5 page.</p> <button class="btn btn-primary">Get Started</button> </div> <!-- Bootstrap JS must be last, just before closing </body> --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Breaking Down the Structure
lang="en" — Declares the page language. Helps screen readers and search engines.
meta charset="UTF-8" — Supports all characters including symbols and special letters.
meta name="viewport" — Critical for Bootstrap. Without this, mobile breakpoints won't work. Always include it.
Bootstrap CSS link — Must be in <head> so styles load before the page renders.
Bootstrap JS script — Goes just before </body> so it loads after all HTML elements exist.
Bootstrap Containers
A container is the outermost wrapper for your Bootstrap content. It controls the maximum width of your page layout and adds horizontal padding on both sides to prevent content from touching the screen edges.
There are three container types in Bootstrap 5:
| Class | Behaviour | Best Used For |
|---|---|---|
| .container | Fixed max-width, responsive per breakpoint | Articles, blogs, lesson pages |
| .container-fluid | Always 100% width of viewport | Full-width headers, footers, banners |
| .container-{bp} | 100% wide until the named breakpoint, then fixed | Specific breakpoint-controlled sections |
<!-- Fixed-width container (centered) --> <div class="container"> <p>Fixed-width — great for article content</p> </div> <!-- Full-width container (edge to edge) --> <div class="container-fluid"> <p>Full-width — great for hero sections and navbars</p> </div> <!-- Full-width on mobile, fixed from medium screens up --> <div class="container-md"> <p>Responsive — stacks on mobile, fixed on medium+</p> </div>
Bootstrap Grid System
The Bootstrap grid divides each row into 12 equal columns. You control how many columns each element spans using classes like col-4 (4 of 12 = one third of the row). The layout structure is always: container → row → columns.
<div class="container"> <div class="row"> <!-- Each col-4 takes 4/12 = one third of the row --> <div class="col-4">Column 1</div> <div class="col-4">Column 2</div> <div class="col-4">Column 3</div> </div> </div>
Responsive column classes
Add breakpoint suffixes to make columns responsive. The column spans its defined width from that breakpoint and above — below it, the column is full width (stacks vertically):
<div class="container"> <div class="row"> <!-- Full width on mobile | Half on md | Third on lg --> <div class="col-12 col-md-6 col-lg-4">Card A</div> <div class="col-12 col-md-6 col-lg-4">Card B</div> <div class="col-12 col-md-6 col-lg-4">Card C</div> </div> </div>
Bootstrap 5 breakpoints
| Breakpoint | Class prefix | Starts at | Typical device |
|---|---|---|---|
| Extra small | col- | < 576px | Portrait phones |
| Small | col-sm- | ≥ 576px | Landscape phones |
| Medium | col-md- | ≥ 768px | Tablets |
| Large | col-lg- | ≥ 992px | Laptops |
| Extra large | col-xl- | ≥ 1200px | Desktops |
| XXL | col-xxl- | ≥ 1400px | Large desktops |
Bootstrap Utility Classes
Utility classes let you style elements instantly with no custom CSS. Every utility maps to a specific CSS property. TipsInLearning uses them throughout this site for spacing, alignment, and colours.
Spacing — m, p
mt-3 = margin-top. pb-4 = padding-bottom. Scale 0–5.
Text — text-*
text-center, text-white, text-muted, text-uppercase.
Colours — bg-*
bg-primary, bg-dark, bg-light, bg-success.
Display — d-*
d-flex, d-none, d-block, d-md-flex.
Sizing — w-*, h-*
w-100 = 100% width. w-50 = 50% width.
Borders — border-*
border, border-0, rounded, rounded-pill.
<!-- Centered heading with bottom margin --> <h1 class="text-center mb-4">TipsInLearning</h1> <!-- Dark background, white text, padding, rounded corners --> <div class="bg-dark text-white p-4 rounded"> Styled box using only utility classes </div> <!-- Full-width button with top margin --> <button class="btn btn-success w-100 mt-3"> Full Width Button </button> <!-- Flex container with centered content --> <div class="d-flex justify-content-center align-items-center gap-3 mt-4"> <button class="btn btn-primary">HTML</button> <button class="btn btn-warning">CSS</button> <button class="btn btn-danger">Bootstrap</button> </div>
Complete Bootstrap Page Example
Here is a complete, production-ready Bootstrap 5 page combining everything covered in this lesson — viewport tag, container, grid, components, and utility classes. Click Run to see it in your browser:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>TipsInLearning Bootstrap Page</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body class="bg-light"> <!-- Full-width dark navbar --> <nav class="navbar navbar-dark bg-dark"> <div class="container"> <a class="navbar-brand fw-bold" href="#">TipsInLearning</a> </div> </nav> <!-- Hero section --> <div class="bg-primary text-white py-5 text-center"> <h1 class="display-5 fw-bold">Learn Bootstrap with TipsInLearning</h1> <p class="lead">Free, beginner-friendly Bootstrap tutorials</p> <a href="#" class="btn btn-light btn-lg">Start Now</a> </div> <!-- Main content with 3-card grid --> <div class="container my-5"> <h2 class="text-center mb-4">Our Courses</h2> <div class="row g-4"> <div class="col-md-4"> <div class="card h-100 shadow-sm"> <div class="card-body"> <h5 class="card-title">HTML</h5> <p class="card-text">Learn the structure of every webpage.</p> <a href="#" class="btn btn-outline-primary btn-sm">Start Course</a> </div> </div> </div> <div class="col-md-4"> <div class="card h-100 shadow-sm"> <div class="card-body"> <h5 class="card-title">CSS</h5> <p class="card-text">Style your pages with confidence.</p> <a href="#" class="btn btn-outline-primary btn-sm">Start Course</a> </div> </div> </div> <div class="col-md-4"> <div class="card h-100 shadow-sm"> <div class="card-body"> <h5 class="card-title">Bootstrap</h5> <p class="card-text">Build responsive sites in hours.</p> <a href="#" class="btn btn-outline-primary btn-sm">Start Course</a> </div> </div> </div> </div> </div> <!-- Footer --> <footer class="bg-dark text-white text-center py-4 mt-5"> <p class="mb-0">© 2026 TipsInLearning. All rights reserved.</p> </footer> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Common Mistakes
These are the errors TipsInLearning sees most often from beginners setting up Bootstrap for the first time:
Without <meta name="viewport" content="width=device-width, initial-scale=1">, Bootstrap's entire responsive system breaks on mobile. The page will appear zoomed out, columns won't stack, and breakpoints won't trigger. This tag is mandatory. Every single Bootstrap page needs it.
Bootstrap JS must go just before </body> — not in <head>. If you put it in the head, the script loads before HTML elements exist, causing interactive components like dropdowns and modals to fail silently.
The grid hierarchy must always be container → row → columns. If you put col-6 directly inside a container without a row, the gutter spacing breaks. If you skip the container entirely, layout width and padding won't work correctly.
Each row has exactly 12 column units. If your columns add up to more than 12 — say two col-7 elements (14 total) — the second one wraps to a new line. Always check that your column widths add up to 12 or less per row.
If you add style.css before the Bootstrap CSS link, Bootstrap's styles will override yours. Always link Bootstrap first, then your own stylesheet so your custom rules take priority.
Questions About Bootstrap Setup
The questions TipsInLearning students ask most when setting up Bootstrap for the first time: