Learn Bootstrap5: Setup Bootstrap Offline in 3 Easy Steps

Updated on Jan 02,2024

Learn Bootstrap5: Setup Bootstrap Offline in 3 Easy Steps

Table of Contents

  1. Introduction
  2. Creating the Root Folder
  3. Adding the HTML Document
  4. Making the HTML Page Mobile-Friendly
  5. Linking the bootstrap.min.css File
  6. Testing the css Link
  7. Linking the jquery.min.js File
  8. Testing the jQuery Library Link
  9. Linking the popper.min.js and bootstrap.min.js Files
  10. Testing the popper.js and bootstrap.js Links
  11. Conclusion

Introduction

In this tutorial, we will learn how to add Bootstrap to our Website. Bootstrap is a popular framework that provides a set of pre-designed CSS and JavaScript components that can be easily incorporated into your web pages. By using Bootstrap, you can Create responsive and visually appealing websites without much coding effort. We will go through the step-by-step process of adding Bootstrap to your website, starting from creating the root folder to styling your web page using Bootstrap classes and JavaScript code.

1. Creating the Root Folder

To incorporate Bootstrap into your website, you will need to create a root folder where you will store all the necessary resources. Create a new folder and name it according to your Website Name. This root folder will serve as the main directory for your website.

2. Adding the HTML Document

Next, create an HTML document with the basic structure of an HTML5 document. You can use any text editor, such as Notepad, to create the HTML file. Save the file inside the root folder with the name "default.html". This file will serve as the main web page for your website.

3. Making the HTML Page Mobile-Friendly

To ensure that your web page is mobile-friendly, we need to add the necessary meta tags to the HTML document. Specifically, we will include the "viewport" meta tag, which sets the width of the HTML page to the width of the device screen. To do this, add the following code inside the head section of your HTML document:

<meta name="viewport" content="width=device-width, initial-Scale=1.0">

This code will make your web page responsive and adapt to different screen sizes.

4. Linking the bootstrap.min.css File

Now, we will link the bootstrap.min.css file to our HTML page. This file contains all the styling rules and classes provided by Bootstrap. In the root folder, you will find the "bootstrap" folder, inside which there is a "CSS" folder. Inside the CSS folder, you will find the "bootstrap.min.css" file. Copy the following code and paste it inside the head section of your HTML document:

<link rel="stylesheet" href="bootstrap/CSS/bootstrap.min.css">

This code will link the bootstrap.min.css file to your HTML page and Apply the Bootstrap styling to your web page.

5. Testing the CSS Link

To test whether the bootstrap.min.css file is properly linked to your HTML page, you can add a simple button and apply the Bootstrap classes to it. Add the following code inside the body section of your HTML document:

<input Type="button" class="btn btn-primary" value="HTML">

Save the changes and refresh the web page in your browser. You should see a button styled with the Bootstrap classes, giving it a nice appearance.

6. Linking the jquery.min.js File

Bootstrap is built on top of the jQuery library, so we need to link the jQuery file to our HTML page. In the root folder, you will find the "jQuery" folder, inside which you will find the "jquery.min.js" file. Copy the following code and paste it at the end of the body section, just before the closing body tag, in your HTML document:

<script src="jQuery/jquery.min.js"></script>

This code will link the jquery.min.js file to your HTML page and allow you to use jQuery functions.

7. Testing the jQuery Library Link

To test whether the jQuery library is properly linked to your HTML page, you can add a simple JavaScript code using jQuery. Add the following code inside a script tag, just after the jQuery link:

<script>
    $(document).ready(function(){
        $("input[name='input']").hide();
    });
</script>

In this code, We Are calling the jQuery function and passing it the CSS selector for the input element with the name "input". We are then using the hide() function to hide the input element. Save the changes and refresh the web page. The input button should be Hidden.

8. Linking the popper.min.js and bootstrap.min.js Files

Bootstrap also relies on the popper.js library for handling tooltips, popovers, dropdowns, and modals. To incorporate this functionality in your website, you need to link the popper.min.js and bootstrap.min.js files to your HTML page. In the root folder, you will find the "popper" folder, inside which you will find the "popper.min.js" file. Copy the following code and paste it after the jQuery link:

<script src="popper/popper.min.js"></script>

Next, link the bootstrap.min.js file by copying the following code and pasting it after the popper.min.js link:

<script src="bootstrap/JS/bootstrap.min.js"></script>

These two code lines will link the popper.min.js and bootstrap.min.js files to your HTML page, enabling the use of Bootstrap's interactive components.

9. Testing the popper.js and bootstrap.js Links

To test whether the popper.js and bootstrap.js files are properly linked to your HTML page, you can add a title attribute to the button element and make it toggle as a tooltip. Add the following code to the input element:

<input type="button" class="btn btn-primary" value="HTML" title="HTML is a structural language" data-bs-toggle="tooltip">

Save the changes and refresh the web page. When you move the mouse over the button, you should see a styled tooltip with the text "HTML is a structural language" appearing.

10. Conclusion

Congratulations! You have successfully added Bootstrap to your website. You have learned how to create the root folder, link the necessary files, and apply Bootstrap styling and functionality to your web page. By utilizing the pre-designed classes and components provided by Bootstrap, you can create visually appealing and responsive websites with ease.

Most people like