Open In App

Bootstrap Tutorial

Last Updated : 01 Jul, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Bootstrap is the most popular open-source front-end framework for simplified web development. It provides a collection of HTML, CSS, and JavaScript components and tools that enable developers to easily build responsive, mobile-first websites.

bootstrap-tutorial-copy-2

Bootstrap Tutorial

This Bootstrap Tutorial is designed for beginners and experienced professionals, covering basics and advanced concepts includes working with Bootstrap CSS classes, incorporating JavaScript plugins, and more.

Prerequisites:

To work with Bootstrap, basic knowledge of HTML, CSS, and JavaScript is recommended as prerequisites.

What is Bootstrap?

Bootstrap is a free and open-source tool collection used to create responsive websites and web applications. It is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. Nowadays, websites created using Bootstrap are compatible with all browsers (IE, Firefox, and Chrome) and with all screen sizes (Desktops, Tablets, Phablets, and Phones). Bootstrap was initially developed by Mark Otto and Jacob Thornton of Twitter, but it was later declared an open-source project.

Bootstrap

Features of Bootstrap:

Bootstrap boasts a treasure trove of pre-built components, including:

  • Grid System: Construct layouts with ease using a flexible grid system that adapts seamlessly to various screen sizes.
  • Forms: Craft user-friendly forms with a variety of styles and functionalities like validation.
  • Buttons: Spice up your website with customizable buttons in all shapes and sizes.
  • Navigation: Implement user-friendly navigation menus, from simple dropdowns to complex mega menus.
  • Alerts: Convey messages effectively through dismissible alerts, warnings, and success notifications.
  • Images: Enhance your website’s visual appeal with responsive image management.
  • JavaScript Plugins: Incorporate interactive elements like modals, tooltips, and carousels with Bootstrap’s JavaScript plugins.

Getting Started with Bootstrap

The first step is incorporating Bootstrap into your project. There are two primary methods:

  1. CDN Links: Embed Bootstrap’s CSS and JavaScript files directly from a Content Delivery Network (CDN) using links within your HTML’s <head> section. This is a swift solution for getting started.
  2. Download Files: For more control, download Bootstrap’s source files from the official website https://getbootstrap.com/. This approach allows you to customize the framework to your specific needs.

Let’s construct the basic structure of a Bootstrap webpage:

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, 
                initial-scale=1.0">
    <title>Your Website Title</title>
    <link href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" 
          rel="stylesheet"
          integrity=
"sha384-0evSXBKJEiCTixQwlqVENU19A2VRQPbucwDTEMspIkz1iBZCTQIWKeWQF/onS0+zI" 
          crossorigin="anonymous">
</head>

<body>
    <script src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js"
        integrity=
"sha384-bhQOshp1dNFTzlpvtEtzn1Q0aaS8breitwLeQuoYwS0DnMTqzhUqFWJuUFNgTboME" 
        crossorigin="anonymous">
        </script>
</body>

</html>

This code establishes the fundamental HTML structure and incorporates Bootstrap’s CSS and JavaScript through CDN links.

HTML
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1">
 
    <!-- Bootstrap CSS library -->
    <link rel="stylesheet"
          href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
          integrity=
"sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
          crossorigin="anonymous">
</head>
 
<body>
    <div class="container text-center">
        <!-- Text color class used -->
        <h1 class="text-success">GeeksforGeeks</h1>
        <p>A computer science portal for geeks</p>
    </div>
</body>
 
</html>

Output:Bootstrap-Output

2. Download Bootstrap from getbootstrap.com

Goto www.getbootstrap.com and click Getting Started. Click on the Download Bootstrap button. Download bootstrap

A.zip file would get downloaded. Extract the zip file and go to the distribution folder. It contains two folders named CSS and JS.

<link rel=”stylesheet” type=”text/css” href=”css/bootstrap.min.css”> <script src=”js/bootstrap.min.js”> </script> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js”></script>


Add the file link to the HTML document and then open the web page using web browsers.

HTML
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1">
           
    <!-- Bootstrap CSS library -->
    <link rel="stylesheet"
          type="text/css"
          href="css/bootstrap.min.css">
           
    <!-- JavaScript library -->
    <script src="js/bootstrap.min.js"></script>
</head>
 
<body>
    <div class="container text-center">
        <!-- Text color class used -->
        <h1 class="text-success">GeeksforGeeks</h1>
        <p>A computer science portal for geeks</p>
    </div>
</body>
 
</html>

Output:

Building with Bootstrap Components

Bootstrap provides a rich assortment of pre-built components to expedite your development process. Let’s explore some widely used ones:

  • Buttons: Implement buttons with various styles, sizes, and functionalities using classes like .btn-primary and .btn-outline-success.
  • Alerts: Convey messages through dismissible alerts with semantic classes like .alert-success and .alert-danger.
  • Images: Incorporate responsive images using the .img-fluid class, ensuring they scale appropriately across devices.
  • Navigation: Craft navigation menus using Bootstrap’s navbar component, which includes support for responsive collapsing on smaller screens.

Learn Bootstrap Step by Step

Recent Articles on Bootstrap

FAQs – Bootstrap Tutorial

What is Bootstrap used for?

Bootstrap is used to build responsive and mobile-friendly websites efficiently, providing a collection of tools, components, and styles that simplify the web development process.

What is Bootstrap in CSS?

Bootstrap in CSS refers to the predefined set of CSS classes and styles provided by the Bootstrap framework, allowing developers to easily enhance the appearance and functionality of HTML elements without extensive custom CSS coding.

Is Bootstrap a free framework?

Yes, Bootstrap is a free and open-source framework. It is available for anyone to use and modify, making it accessible to developers of all levels. Bootstrap’s open-source nature allows for community contributions, updates, and improvements, ensuring its continuous evolution and widespread adoption in the web development community.



Similar Reads

Include Bootstrap in AngularJS using ng-bootstrap
AngularJS can be integrated with Bootstrap CSS and Javascript and can be used to create creative forms, tables, navigation bars, etc. Steps: Make sure the Angular CLI present in your system if not then run the command in the terminal to do so. npm install -g @angular/cli Create a new project on visual studio code by running the code ng new project-
2 min read
Difference between bootstrap.css and bootstrap-theme.css
Bootstrap is an HTML, CSS and JS front-end-framework used for developing responsive and mobile-first projects on the web. It is the framework that comes up with predefined terms, thus giving you the ability to use these codes instead of having to create the codes from scratch. It is a collection of HTML, CSS and JS code that is designed to help bui
5 min read
Difference Between Bootstrap 3 and Bootstrap 4
Bootstrap: Bootstrap was developed by Mark Otto and Jacob Thorton at Twitter in August 2011. It is an open-source framework that is used to design responsive websites faster and easier. It is the most popular open-source framework that includes HTML, CSS, and JavaScript. It can create web applications with any server-side Technology like Java, PHP,
2 min read
Difference between Bootstrap 4 and Bootstrap 5
What is Bootstrap? It is an open-source framework from late 2011 that is used for designing responsive websites with a mobile-first approach faster and easier. Bootstrap is available for HTML, CSS, and JS. According to server-side languages like PHP, Node, etc. bootstrap helps to design the frontend. Bootstrap has made the work for developers easie
3 min read
Bootstrap Cheat Sheet - A Basic Guide to Bootstrap
Bootstrap is a free, open-source, potent CSS framework and toolkit used to create modern and responsive websites and web applications. It is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. Nowadays, websites are perfect for all browsers and all sizes of screens. What is Bootstrap Cheat Sheet?A
15+ min read
Bootstrap Buttons, Glyphicons, Tables
Introduction and Installation Grid System Vertical Forms, Horizontal Forms, Inline Forms DropDowns and Responsive Tabs Progress Bar and Jumbotron After the previous article, one should be familiar with the Grid System of Bootstrap. Now, we'll learn about making Buttons, the all new Glyphicons and Tables. Lets get started. Beautiful Buttons: We can
4 min read
Bootstrap DropDowns and Responsive Tabs
Introduction and InstallationGrid SystemButtons, Glyphicons, TablesVertical Forms, Horizontal Forms, Inline FormsProgress Bar and Jumbotron Dropdown Menu Using Bootstrap: In bootstrap, dropdowns are created using the class="dropdown". What we will do is create a button and then convert the button into a dropdown.As already stated in the last few tu
3 min read
Bootstrap 5 Reboot Misc elements
Bootstrap 5 Reboot Misc elements are some other tags that are used to reset browser defaults and can be used when we do not want to specify CSS explicitly. Reboot Misc Elements: Address: Reboot Address element is used to change the font style from italic to normal text. It inherits line height and the margin-bottom is set to 1 rem.Blockquote: This
2 min read
How to get circular buttons in bootstrap 4 ?
It is an open source toolkit for developing with the HTML, CSS, and JS. It includes several types of buttons, styles, fonts each of them serving its own semantic purpose which is predefined, with a few extras thrown for more control. You can use Bootstrap custom button styles to create your buttons and more with support for multiple sizes, states,
2 min read
Bootstrap 5 Spinners Border
Bootstrap 5 Spinner is used to show the loading stage of the component, these spinners are built only with HTML and CSS. The Border Spinner is used for a lightweight loading indicator. To change, etc. the spinners color we need to use the Bootstrap 5 Text Color classes, like text-primary, text-success Spinner Border Classes: spinner-border: This cl
2 min read
three90RightbarBannerImg