Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • BS5 Tutorial
  • BS5 Interview Questions
  • BS5 Layout
  • BS5 Content
  • BS5 Components
  • BS5 Helpers
  • BS5 Utilities
  • BS4 Tutorial
  • BS Tutorial
  • Bootstrap Cheatsheet
  • Tailwind
  • CSS Frameworks
  • HTML Formatter
Open In App
Next Article:
How to Add Bootstrap in a Project?
Next article icon

How to Add Bootstrap in a Project?

Last Updated : 16 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Bootstrap is a popular open-source framework for building responsive and mobile-first websites using HTML, CSS, and JavaScript. It provides pre-designed components and templates that simplify web development.

Why Use Bootstrap?

Bootstrap offers several advantages for web development:

  • Faster and Easier Development: Pre-designed components save time.
  • Responsive Design: Bootstrap ensures your website looks good on all devices, including mobile phones.
  • Cross-Browser Compatibility: Bootstrap pages work across different browsers without extra code.
  • Free and Open-Source: Available at getbootstrap.com.

Methods to Add Bootstrap to Your Project

Method 1: Using CDN Links

The easiest way to use Bootstrap is through CDN links, which allow you to load Bootstrap from a remote server. This method requires a stable internet connection but is quick to implement.

Steps to Add Bootstrap via CDN:

Step 1: Goto getbootstrap and click Getting Started. There you will find the below CDN links. 

Step 2: Copy the CDN Links: You will need both the CSS and JavaScript CDN links.

CSS link:

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">

JavaScript link:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>

Step 3: Insert Links in Your HTML Document: Paste the links inside the <head> tag for the CSS and inside the <body> tag for the JavaScript.

Here’s an example of how your HTML file should look:

HTML
<!DOCTYPE html> <html lang="en"> <head>     <!-- Meta tags for responsive design -->     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">          <!-- Bootstrap CSS -->     <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"            rel="stylesheet"            integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU"            crossorigin="anonymous">          <title>Bootstrap Project</title> </head> <body>      <h1 class="text-center">Hello, Bootstrap!</h1>      <!-- Bootstrap JavaScript -->     <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"              integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ"              crossorigin="anonymous"></script> </body> </html> 

 Output:

bootstrap-via-cdn
Bootstrap via CDN

Method 2: Downloading Bootstrap Files

Alternatively, you can download the Bootstrap files and include them locally in your project. This method allows you to work offline.

Step 1: Goto getbootstrap and click Getting Started. Click on the Download Bootstrap button and download the compiled CSS and JS.

Step 2: Extract the Files: Once downloaded, extract the files. You will find folders like css, js, and fonts (if needed).

Step 3: Include Bootstrap in Your Project: In your HTML file, link the local files by specifying the correct path.

  • CSS File:
<link rel="stylesheet" href="path/to/bootstrap/css/bootstrap.min.css">
  • JavaScript File:
<script src="path/to/bootstrap/js/bootstrap.bundle.min.js"></script>

Step 4: After completing the above steps, the final code will look like the following code example. The final code after saving files under the same folder and adding links under the head and body tag respectively.

Example: In the example, it can be observed that the downloaded files from bootstrap are included under the head and body section. Now the bootstrap classes can directly be used. As it is downloaded, thus no need for an internet connection required to load classes of bootstrap.

HTML
<!DOCTYPE html> <html lang="en">  <head>      <!-- Required meta tags -->     <meta charset="utf-8" />     <meta name="viewport" content="width=device-width, initial-scale=1" />      <link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> </head>  <body>     <h1>Welcome to GeeksforGeeks</h1>      <div class="mb-3">         <label for="exampleFormControlInput1" class="form-label">             Email address         </label>          <input type="email" class="form-control" id="exampleFormControlInput1"                 placeholder="[email protected]" />     </div>      <div class="mb-3">         <label for="exampleFormControlTextarea1" class="form-label">             Example textarea         </label>          <textarea class="form-control" id="exampleFormControlTextarea1" rows="3">       </textarea>     </div>      <script type="text/javascript" href="js/jquery.js">     </script>      <script type="text/javascript" href="js/bootstrap.min.js">     </script> </body>  </html> 

 Output:

Bootstrap_local_file

Next Article
How to Add Bootstrap in a Project?

S

skbhoyar36sb
Improve
Article Tags :
  • Web Technologies
  • Bootstrap
  • Bootstrap-4
  • HTML-Questions
  • Bootstrap-Questions

Similar Reads

    How to add icons in project using Bootstrap ?
    Bootstrap Icons is an open-source icon library specifically designed for use with Bootstrap's framework. Adding icons using Bootstrap means integrating the Bootstrap Icons library into your project and using its icon classes in HTML. This allows easy inclusion of scalable, customizable icons directl
    2 min read
    How to use Bootstrap in React JS ?
    Explore the seamless integration of Bootstrap into React JS for enhanced styling and responsive web development. This comprehensive guide provides step-by-step instructions, covering the installation process, utilization of Bootstrap components, and best practices to harness the power of both techno
    3 min read
    How to install Bootstrap 5?
    Bootstrap 5, a popular front-end framework, empowers developers to create sleek and responsive websites with minimal effort. To install Bootstrap 5, you can choose from three methods including CDN links for quick integration, employ package managers like npm for seamless dependency management, or ma
    5 min read
    How to Install Bootstrap in Angular?
    If you have completed your practice in the field of HTML & CSS and want to develop more interesting and attractive webpages in the future, moving ahead for the Bootstrap topic along with the Angular concept will be appropriate for you. However, to have Bootstrap on your Angular Project you shoul
    5 min read
    How To Install Bootstrap in ReactJS?
    Bootstrap is one of the most popular CSS frameworks for developing responsive and mobile-first websites. Integrating Bootstrap with ReactJS helps you build sleek, responsive interfaces quickly and easily. In this article, we will walk you through the step-by-step process of installing Bootstrap in R
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences