Installation Guide
This guide covers the different ways to install Bootstrap so you can get started quickly.
What You Need
Bootstrap 5 needs:
- A modern browser with HTML5 support
- CSS3 support
- JavaScript ES6+ (if you're using JavaScript plugins)
Installation Options
Option 1: CDN (Recommended)
The quickest way to get going is to include Bootstrap's CSS and JavaScript directly from a CDN:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap Page</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h1>Hello, Bootstrap!</h1>
<!-- Bootstrap JavaScript (includes Popper) -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Option 2: npm Install
If you're using npm to manage your project dependencies:
# Install Bootstrap
npm install bootstrap@5
# Install Popper (needed for dropdowns, tooltips, etc.)
npm install @popperjs/core
Then import in your project:
// Import Bootstrap's CSS
import 'bootstrap/dist/css/bootstrap.min.css';
// Import Bootstrap's JS
import 'bootstrap/dist/js/bootstrap.bundle.min.js';
Option 3: Download Source Files
Grab the pre-compiled files from the official website:
- Go to https://getbootstrap.com/
- Click the "Download" button
- Choose "Compiled CSS and JS"
- Unzip and copy the css and js folders into your project
Your directory structure should look like this:
your-project/
├── css/
│ └── bootstrap.min.css
├── js/
│ └── bootstrap.bundle.min.js
└── index.html
Option 4: Sass Source
If you need to customize Bootstrap's styles, you can work with the Sass source:
npm install bootstrap
Then import in your Sass file:
// Custom variables (define before importing Bootstrap)
$primary: #007bff;
$body-bg: #f8f9fa;
// Import Bootstrap
@import "~bootstrap/scss/bootstrap";
Development Tools
VS Code Extensions
These extensions come in handy:
- Bootstrap 5 Snippets — gives you ready-made component code snippets
- HTML CSS Support — auto-completes CSS class names
- Live Server — preview your pages in real-time
Online Editors
- Bootstrap Builder — visual drag-and-drop Bootstrap page builder
- Bootstrap Studio — professional Bootstrap design tool
Quick Start
Your First Page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap Quick Start</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="#">My Website</a>
</div>
</nav>
<!-- Main Content -->
<main class="container mt-5">
<div class="row">
<div class="col-md-6">
<h1>Welcome to Bootstrap</h1>
<p class="lead">This is a responsive page built with Bootstrap 5.</p>
<button class="btn btn-primary">Learn More</button>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Features</h5>
<ul>
<li>Responsive layout</li>
<li>Rich components</li>
<li>Powerful JavaScript plugins</li>
</ul>
</div>
</div>
</div>
</div>
</main>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Which Version to Use
Production
Use the stable release:
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
Development
Use the latest development version (includes source maps):
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.js"></script>
China CDN Mirror
For faster loading in China:
<link href="https://cdn.bootcss.com/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
Uninstalling
If you need to remove Bootstrap (just delete the files):
- Remove the CSS and JS links from your HTML
- Delete the bootstrap folder from node_modules (if using npm)
- Delete locally downloaded CSS and JS files
Next Steps
Once you've got Bootstrap installed, check out these docs to go deeper:
- User Manual — grid system, components, and more
- FAQ — common questions answered
