Table of contents
1.
Introduction
2.
Why Use Bootstrap?
3.
Methods to Add Bootstrap to Your Project
3.1.
1. Adding Bootstrap via CDN
3.1.1.
Steps to Include Bootstrap via CDN
3.1.2.
Example:
3.2.
2. Adding Bootstrap Locally
3.2.1.
Steps to Include Bootstrap Locally
3.2.2.
Example:
4.
Examples from Creative Tim  
4.1.
Step 1: Download the Template  
4.2.
Step 2: Extract & Organize Files  
4.3.
Step 3: Link the Files in Your HTML  
4.4.
Step 4: Customize the Template  
5.
Frequently Asked Questions
5.1.
Can I use Bootstrap with other CSS frameworks?
5.2.
Which method is better: CDN or local installation?
5.3.
Does Bootstrap require JavaScript?
6.
Conclusion
Last Updated: Feb 23, 2025
Medium

How to Include Bootstrap in HTML?

Author Gaurav Gandhi
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Including Bootstrap in HTML helps developers create responsive and stylish web pages easily. Bootstrap offers pre-designed CSS classes and JavaScript components for faster development. You can add Bootstrap using a CDN (Content Delivery Network) or by downloading and linking the files locally. 

How to Include Bootstrap in HTML?

In this article, you will learn both methods and how to use Bootstrap efficiently to enhance the design and functionality of your web pages.

Why Use Bootstrap?

  1. Responsive Design – Bootstrap ensures that web pages adjust to different screen sizes automatically.
     
  2. Pre-designed Components – It offers buttons, modals, carousels, and other UI elements that save time.
     
  3. Consistency – Websites built with Bootstrap maintain a uniform look across different devices and browsers.
     
  4. Grid System – A flexible and easy-to-use 12-column grid system simplifies layout design.
     
  5. Browser Compatibility – Bootstrap works well with modern browsers, ensuring a smooth user experience.

Methods to Add Bootstrap to Your Project

There are two primary ways to add Bootstrap to your HTML file:

  1. Using a CDN (Content Delivery Network) – Quick and easy method.
     
  2. Downloading Bootstrap and Hosting it Locally – Suitable for offline development or customization.

1. Adding Bootstrap via CDN

The simplest way to include Bootstrap is by linking to its CDN. This method ensures fast loading times and always provides the latest version.

Steps to Include Bootstrap via CDN

  1. Open your HTML file in any text editor.
     
  2. Add the following <link> tag inside the <head> section to include Bootstrap CSS.
     
  3. Add the Bootstrap JavaScript and Popper.js files before the closing <body> tag.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bootstrap CDN Example</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container text-center">
        <h1 class="text-primary">Hello, Bootstrap!</h1>
        <button class="btn btn-success">Click Me</button>
    </div>
    
    <!-- Bootstrap JS and dependencies -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

 

Output:

Output
  • The webpage will display a blue "Hello, Bootstrap!" heading and a green button labeled "Click Me".
     
  • The page will be responsive without additional CSS.

2. Adding Bootstrap Locally

If you want to use Bootstrap without relying on an internet connection, you can download it and use it locally.

Steps to Include Bootstrap Locally

  1. Download Bootstrap from the official website: https://getbootstrap.com
     
  2. Extract the downloaded ZIP file.
     
  3. Copy the bootstrap.min.css and bootstrap.min.js files into your project folder.
     
  4. Link the Bootstrap files in your HTML document.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bootstrap Local Example</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
    <div class="container text-center">
        <h1 class="text-warning">Bootstrap Loaded Locally</h1>
        <button class="btn btn-danger">Click Me</button>
    </div>
    
    <!-- Bootstrap JS -->
    <script src="js/bootstrap.bundle.min.js"></script>
</body>
</html>

 

Output:

Output
  • The webpage will display a yellow "Bootstrap Loaded Locally" heading and a red button labeled "Click Me".
     
  • No internet connection is needed to load Bootstrap.

Examples from Creative Tim  

Creative Tim is a platform that offers free & premium templates based on Bootstrap. These templates are designed to help developers quickly build professional-looking websites without starting from scratch. They provide ready-to-use components, layouts, & design elements that align with modern web standards.  

One popular example is the "Material Kit" by Creative Tim. It’s a free Bootstrap UI kit inspired by Google’s Material Design. This kit includes pre-styled buttons, cards, forms, & navigation bars that you can directly integrate into your project. Let’s learn how to use one of these templates in your HTML project.  

Step 1: Download the Template  

Visit the [Creative Tim website](https://www.creative-tim.com/) & browse their free templates. For this example, we’ll use the "Material Kit" template. Click on the download button to get the ZIP file containing all the necessary files.  

Step 2: Extract & Organize Files  

Once downloaded, extract the ZIP file to a folder on your computer. Inside, you’ll find folders like `css`, `js`, & `assets` along with an `index.html` file. These files contain the styles, scripts, & images used in the template.  

Step 3: Link the Files in Your HTML  

To use the template, link the CSS & JavaScript files in your HTML document. For example:  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Creative Tim Example</title>
    <!-- Link to Material Kit CSS -->
    <link href="assets/css/material-kit.css" rel="stylesheet">
</head>
<body>
    <div class="container mt-5">
        <h1 class="text-center">Welcome to My Website</h1>
        <button class="btn btn-primary">Click Me</button>
    </div>
    <!-- Link to Material Kit JS -->
    <script src="assets/js/material-kit.js"></script>
</body>
</html>

 

Output

Output

In this example, the `material-kit.css` file provides the styling, while `material-kit.js` adds interactivity. Make sure the file paths match the location of the extracted files on your system.  

Step 4: Customize the Template  

Creative Tim templates are highly customizable. You can modify the colors, fonts, & layouts by editing the CSS files or using the provided SASS variables. For instance, if you want to change the primary color of the buttons, locate the relevant variable in the SASS file & update it.  

Using templates like those from Creative Tim not only speeds up development but also ensures your website follows modern design trends. These templates are great for students learning web development as they provide practical examples of how Bootstrap components work together.  

Frequently Asked Questions

Can I use Bootstrap with other CSS frameworks?

Yes, but you need to manage conflicting styles carefully to avoid design issues.

Which method is better: CDN or local installation?

CDN is faster and easier, but local installation is useful when working offline or customizing Bootstrap.

Does Bootstrap require JavaScript?

Basic Bootstrap features work with just CSS, but some components like modals and tooltips require JavaScript.

Conclusion

In this article, we discussed how to include Bootstrap in HTML using methods like CDN links and installing via npm. By adding Bootstrap’s CSS and JS files, we can quickly style web pages and create responsive designs. Understanding how to integrate Bootstrap helps in building modern, mobile-friendly websites efficiently.

Live masterclass