The Wayback Machine - https://web.archive.org/web/20240926185115/https://www.geeksforgeeks.org/bootstrap/
Open In App

Bootstrap Tutorial

Last Updated : 08 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Bootstrap is a most popular front-end framework that simplifies web design by providing a responsive grid system, pre-designed components, and customizable utilities. It is designed to help developers to create quickly modern, visually appealing websites and applications.It streamlines the development process with its easy-to-use tools and mobile-first approach. This tutorial will guide you through mastering Bootstrap’s features for efficient web development.

Prerequisites to Learn Bootstrap

Before start learning to Bootstrap, it is essential to have a foundational understanding of the following:

  • HTML: Knowledge of HTML is essential before starting with Bootstrap. Bootstrap relies on HTML elements and structure to create responsive layouts and components effectively.
  • CSS: Familiar with CSS is necessary to customize Bootstrap’s styling and understand how it integrates with your own styles.
  • Basic JavaScript: Understanding basic JavaScript helps in using Bootstrap’s interactive components, such as modals and carousels, which require JavaScript for functionality.
  • Responsive Design Concepts: An understanding of responsive design principles will help you utilize Bootstrap’s grid system and media queries effectively to create adaptable layouts.

What is Bootstrap?

Bootstrap is a free and open-source toolkit designed for building responsive websites and web applications. It is one of the most popular CSS frameworks. Bootstrap help developers to create mobile-first, adaptive web designs that work seamlessly across all devices and screen sizes. Originally developed by Mark Otto and Jacob Thornton at Twitter. Bootstrap has evolved into a widely-used framework, ensuring compatibility with major browsers like Internet Explorer, Firefox, and Chrome.

CSS Frameworks – Bootstrap

CSS frameworks are pre-designed libraries that simplify web development by providing ready-to-use CSS components and styles. It enable faster, consistent, and responsive web design across various devices and browsers. It enhance the efficiency and ensures a uniform look without repetitive coding. Popular examples include Bootstrap and Tailwind CSS.

CSS-Framework---Bootstrap
CSS Frameworks

History and Evolution of Bootstrap

Bootstrap was created by Mark Otto and Jacob Thornton at Twitter in 2011. It was released as an open-source project, quickly gaining traction for its user-friendly and adaptable framework. Bootstrap 1.0 introduced a responsive grid system and basic components. Subsequent versions, including Bootstrap 2.0 and 3.0, enhanced its features with more sophisticated components, improved grid systems, and mobile-first design principles. The release of Bootstrap 4.0 marked a significant shift with Flexbox support and updated design elements. The latest version, Bootstrap 5.0, further refines the framework with improved customization options and new utilities, reflecting its ongoing evolution to meet modern web design needs.

Bootstrap-Tutorial

Why Use Bootstrap?

Bootstrap simplifies web development by offering a responsive, mobile-first framework with pre-designed components. It streamlines the creation of modern, professional websites with its easy-to-use grid system and built-in JavaScript plugins. With extensive browser compatibility and a strong community, Bootstrap accelerates development time, ensuring consistent and visually appealing designs across all devices.

Getting Started with Bootstrap

1. Setting Up Your Environment

To start using Bootstrap, ensure you have a basic development environment set up. Install a code editor like VSCode or Sublime Text, and ensure you have a local server environment or are comfortable with live server options in your code editor. Bootstrap works with any web server setup, so you can choose the one that best fits your workflow.

2. Including Bootstrap in Your Project

Bootstrap can be included in your project either via a Content Delivery Network (CDN) or by downloading it directly.

Without downloading the Bootstrap, you can directly use CDN links within your HTML file <head> section.

<link href=”https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css” rel=”stylesheet” integrity=”sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH” crossorigin=”anonymous”>

<script src=”https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js” integrity=”sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz” crossorigin=”anonymous”></script>

2.2. Download the Bootstrap File Locally and use in a Project

Alternatively, download the Bootstrap files from the official website (https://getbootstrap.com/) and include them in your project directory. Then, link to the local files in your HTML.

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>

3. Bootstrap Basic Structure and Example

To create a basic Bootstrap layout, start with the essential HTML structure. Here’s a simple example to get you started:

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, 
                initial-scale=1.0">

    <title>Bootstrap Basic Example</title>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
        crossorigin="anonymous"></script>
</head>

<body>
    <div class="container text-center">
        <h1 class="text-success">
            Welcome to GeeksforGeeks
        </h1>

        <p>A Simple Example of Bootstrap</p>
    </div>
</body>

</html>

Output

Bootstrap-Example-Output

Steps to Start Learning Bootstrap

1. Bootstrap Layout

Bootstrap layout is built on a flexible grid layout that adjusts seamlessly to different screen sizes. It uses a 12-column grid system to create responsive designs. You can control the width and positioning of columns by combining classes for different screen sizes (e.g., .col-md-6 for medium devices). The layout also includes containers and rows to structure your content effectively.

2. Bootstrap Content

Bootstrap provides a range of classes to enhance and structure content. It includes typography classes for headings, paragraphs, and text alignment, as well as helper classes for spacing and text colors. Bootstrap’s content classes make it easy to format text, create responsive images, and manage layout in a consistent and visually appealing manner.

3. Bootstrap Forms

Bootstrap simplifies form creation with pre-styled components and layouts. It includes classes for form controls like text inputs, select menus, and checkboxes. Forms can be easily customized with various input sizes, validation states, and layout options. Bootstrap also supports form groups and custom form elements to enhance usability and appearance.

4. Bootstrap Components

Bootstrap offers a rich set of pre-designed components to streamline UI development. These include buttons, cards, modals, navbars, and more. Each component is customizable and responsive, ensuring that your web application maintains a consistent look and feel across different devices and screen sizes.

5. Bootstrap Helpers

Bootstrap helpers are utility classes that simplify common tasks and improve readability. They include classes for text alignment, visibility, display properties, and more. Helpers make it easy to adjust elements without writing custom CSS, speeding up development and ensuring consistency.

6. Bootstrap Utilities

Bootstrap utilities are small, reusable classes that provide additional functionality and control. They include classes for spacing, alignment, borders, and background colors. Utilities help fine-tune the appearance of elements quickly and efficiently, allowing for flexible and responsive design adjustments.

Features of Bootstrap

Bootstrap offers an extensive array of pre-built components designed to streamline web development:

  • Grid System: Easily create responsive layouts with a flexible grid system that adjusts seamlessly to various screen sizes.
  • Forms: Build user-friendly forms with diverse styles and functionalities, including validation.
  • Buttons: Add customizable buttons of all shapes and sizes to enhance your website’s interactivity.
  • Navigation: Implement intuitive navigation menus, from simple dropdowns to advanced mega menus.
  • Alerts: Effectively communicate with dismissible alerts, warnings, and success notifications.
  • Images: Improve your website’s visual appeal with responsive image handling.
  • JavaScript Plugins: Integrate interactive features like modals, tooltips, and carousels using Bootstrap’s JavaScript plugins.

Advantages of using Bootstrap

  • Responsive Design: Bootstrap automatically adjusts the layout to fit different screen sizes and devices, ensuring a consistent user experience across desktops, tablets, and smartphones.
  • Predefined Styles and Components: It offers a library of ready-to-use components (buttons, forms, navigation bars) and styles, reducing development time and effort.
  • Mobile-First Approach: It is designed with a mobile-first philosophy, ensuring that web applications are optimized for mobile devices and then scaled up for larger screens.
  • Customizable and Scalable: It allows easy customization through variables and mixins, and scales with your project’s needs as it grows.
  • Grid System: Utilizes a flexible grid system to create complex layouts with ease, accommodating various screen sizes and content requirements.
  • JavaScript Plugins: Includes a range of built-in JavaScript plugins for interactive elements like modals, carousels, and tooltips, enhancing functionality without additional coding.
  • Documentation and Community Support: Offers extensive documentation and a large community of users for support, tutorials, and best practices, making it easier to find solutions and guidance.
  • Ease of Integration: Easily integrates with various web technologies and frameworks, including HTML, CSS, and JavaScript, making it a versatile choice for different projects.

Disadvantages of using Bootstrap

  • Learning Curve: Requires learning Bootstrap’s classes, grid system, and customization options, which may be challenging for beginners.
  • Limited Customization: While customizable, modifying Bootstrap to fit specific design requirements can be cumbersome and may require overriding default styles extensively.
  • Overuse of Classes: Encourages the use of numerous classes in HTML elements, which can make the code harder to read and maintain.
  • Complex Layouts: While it simplifies many aspects, creating complex or highly customized layouts might require extensive overrides and custom CSS.

Recent Articles on Bootstrap

Bootstrap Tutorial – FAQs

What is Bootstrap?

Bootstrap is an open-source front-end framework designed to streamline and accelerate web development. It provides a collection of CSS, JavaScript, and design templates for creating responsive and mobile-first websites and applications. Bootstrap simplifies the process of designing and building web pages by offering a set of pre-styled components and a responsive grid system.

What is Bootstrap used for?

Bootstrap is used for developing responsive and visually appealing web pages and applications. It offers a variety of pre-designed components, such as navigation bars, buttons, forms, and modals, that help developers quickly create consistent and functional user interfaces. Bootstrap’s grid system ensures that web pages adjust seamlessly across different devices and screen sizes.

What is Bootstrap CDN?

Bootstrap CDN (Content Delivery Network) is a service that allows developers to include Bootstrap’s CSS and JavaScript files in their projects without needing to host them locally. By linking to Bootstrap’s CDN, you can leverage fast, reliable, and globally distributed servers to deliver Bootstrap’s resources, reducing load times and improving website performance.

What is the current Bootstrap version?

As of the most recent update, the current stable version of Bootstrap is Bootstrap 5. Bootstrap 5 includes new features, enhancements, and changes compared to previous versions, such as the removal of jQuery dependency and improved customizability. For the most up-to-date information, it’s recommended to check Bootstrap’s official website or documentation.

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.

Which is better, Tailwind or Bootstrap?

The choice between Tailwind and Bootstrap depends on your project needs and preferences.

  • Bootstrap: Offers a comprehensive set of pre-styled components and a grid system, making it easier to quickly build and customize web pages with a consistent design.
  • Tailwind CSS: Provides a utility-first approach, allowing for more granular and flexible customization of styles without predefined components. Tailwind is ideal for projects where fine-tuned design control and custom styles are required.

Both frameworks have their strengths, and the best choice depends on your specific requirements and design goals.

Can I customize Bootstrap?

Yes, Bootstrap is highly customizable. You can override default styles using custom CSS or modify Bootstrap’s SASS variables to change the look and feel of components globally. Additionally, you can create custom themes by adjusting Bootstrap’s color schemes, typography, and spacing.



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 Alerts , Wells, Pagination and Pager
Introduction and InstallationGrid SystemButtons, Glyphicons, TablesVertical Forms, Horizontal Forms, Inline FormsDropDowns and Responsive TabsProgress Bar and Jumbotron Alerts: We often see certain alerts on some websites before or after completing an action. These alert messages are highlighted texts that are important to take into consideration w
4 min read
Bootstrap Badges, Labels, Page Headers
Introduction and InstallationButtons, Glyphicons, TablesVertical Forms, Horizontal Forms, Inline FormsDropDowns and Responsive TabsProgress Bar and Jumbotron Badges: We all have seen some numerical indicators beside some links on various websites. These are called badges. These badges tell how many items are available or associated with the link. T
3 min read
Bootstrap Tooltips
In this article, we would be discussing the tooltip plugin provided by bootstrap. Tooltip is quite useful for showing the description of different elements in the webpage. Tooltip can be invoked on any element in a webpage. Tooltips on bootstrap depends on the 3rd party library Tether for positioning. Hence, we need to include tether.min.js before
4 min read
Bootstrap 5 Checks and Radios Disabled
Bootstrap 5 Checks and radios Disabled is used to make a checkbox/radio disabled, which means we won't be able to click on it. Its appearance will also get muted. Add the disabled attribute and the associated &lt;label&gt;s are automatically styled with a lighter color to indicate its disabled state. Bootstrap 5 Checks and Radios Disabled Class: Th
2 min read
Difference between Bootstrap and AngularJS
Bootstrap is a free and open source front-end web development framework. It is a giant collection of HTML, CSS, and JavaScript code that is designed to help build user interface components. It is a free collection of tools for creating websites and web applications. It is used by many developers and according to the official Bootstrap site: It is t
5 min read
Bootstrap 5 Navbar Supported Content
Bootstrap 5 Navbar Supported content contains Navbar which supports various sub-components like .navbar-brand, .navbar-nav, .navbar-text, .navbar-toggler, and .navbar-scroll. Brand: It is a company, project, or product name. We add .navbar-brand to various components like a heading or a link. We can add an image, text, or both image and text as our
2 min read
Bootstrap 5 Reboot Address
Bootstrap 5 Reboot is a collection of element-specific CSS that changes in a single file, kickstart Bootstrap provides an elegant, consistent, and simple baseline to build upon. Reboot Address element is used to change the font-style from italic to the normal text. It inherits the line-height property and set the margin-bottom property to 1rem. The
2 min read
Bootstrap | Badges and Breadcrumbs
Badges: Badges are numbers associated with the link to indicate the number of items associated with the link. The notification number is seen when logged in to a particular website and tells the numbers of news or notifications to see by clicking it. Example: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;badge example&lt;/
4 min read
How to make Timepicker using Angular UI Bootstrap ?
In this article, we will see how to make Dropdown using Angular UI bootstrap. Angular UI Bootstrap is an Angular JS framework created by Angular UI developers to provide better UI which can be used easily. Syntax: &lt;div uib-timepicker&gt;&lt;/div&gt; Download AngularUI from the link: https://angular-ui.github.io/bootstrap Approach: First, add Ang
1 min read
How to Apply Bootstrap Grid for Inline Elements ?
The Bootstrap Grid System is a flexible and responsive layout system that allows developers to create complex and responsive web layouts. The grid system uses a series of classes and CSS styles to create rows and columns. The grid system is built using the flexbox layout model, which allows elements to be easily resized and repositioned based on th
4 min read
How to create a two tone banner in bootstrap ?
Bootstrap is a CSS framework used to design webpages. It is the most widely used CSS framework all over due to its simplicity and ease of implementation. Bootstrap is used along with HTML and JavaScript to make the webpages interactive. Banners are section in the webpage that call for extra attention. There can be multiple banners in a webpage and
3 min read
How to write a form in different line using Bootstrap ?
Bootstrap is an open-source front-end framework for developing standard &amp; decorative websites or web applications that are fast and user-friendly. Bootstrap includes templates based on HTML and CSS for tables, forms, buttons, etc. Bootstrap also uses JavaScript and helps us to create responsive designs. Forms are a crucial building block of eve
2 min read
How to configure modal width in Bootstrap?
Bootstrap Modal: It is a dialog window that opens inside the browser window on triggering certain events. It is a really convenient way to improve the website's content rendering as per the requirements. In this article, we will focus on adjusting the width/height of the modal box.Method 1: Using pre-defined Bootstrap classes Bootstrap has pre-defi
2 min read
How to remove arrow in dropdown in Bootstrap ?
Dropdowns are one of the important components that are an integral part of any web application. Bootstrap provides its own interactive version of this component. Bootstrap dropdowns are toggled by clicking, not hovering as it was an intentional design decision. To use Dropdowns in a web project, include Popper.js into the project. Every Bootstrap d
2 min read
Bootstrap 5 Layout Form Grid
Bootstrap 5 Layout Form Grid is used to create a complex form using grid classes. The form grid layout required multiple columns of different widths and alignments. To create a form grid, we use .row and .col classes. Form Grid Layout used Classes: .row: This class is used to create a row of a form layout..col: This class is used to create columns
2 min read
Visibility of elements in bootstrap with Examples
There are some situations where it is needed to hide some content on a webpage without affecting the layout of the page. Bootstrap uses the CSS visibility property and provide two classes visible and invisible to control the visibility of an element on a web page.These classes do not affect the layout i.e. invisible elements will still take up spac
3 min read
Bootstrap 5 Text
In this article, we will discuss how to change the alignment, weight, line height, wrapping, font size of the text, and more with the help of Bootstrap 5 utilities. Text alignment: We can use text alignment classes to align the text in different positions in different viewports.Text wrapping and overflow: To wrap a text we need to use the .text-wra
4 min read
Vertical alignment in Bootstrap with Examples
Vertical Alignment in bootstrap changes the alignment of elements vertically with the help vertical-alignment utilities. The vertical-align utilities only affects inline(Present in one Line), inline-block(Present as blocks in one line), inline-table, and table cell(Elements in a cell of a table) elements.Various classes available in bootstrap libra
2 min read
List group in bootstrap with examples
List Groups are used to display a series of content. We can modify them to support any content as per our needs. The use of List-Groups is just to display a series or list of content in an organized way. Below is a basic List Group created using unordered_lists in HTML, and appropriate Bootstrap classes: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html
4 min read
Bootstrap | Close Icon for dismissing content with Examples
The close icon in bootstrap is a utility that is used to dismiss any content (e.g., Alerts, Modals, Popovers). It is represented by a generic cross/close icon.Below is a sample HTML code including a close icon for dismissing content in bootstrap: C/C++ Code &lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;!-- Bootstrap CSS --&gt; &lt;link rel=
2 min read
Bootstrap | figure class with Examples
A figure is used when one needs to display a piece of content, generally images with an optional caption. The figure class in Bootstrap is used to add styling to the default figure elements. The base .figure class is used to indicate a figure element. The .figure-img is used to indicate the image used in the figure element. The .figure-caption may
1 min read