Author: saqibkhan

  • Collpasev

    This chapter will discuss about Bootstrap collpase. Collasping is toggling the content visibility. This is achieved using bootstrap’s javaScript plugins and some classes.

    • The JavaScript plugin for collapse is used to display and hide information. Buttons or anchors act as triggers when mapped to specific elements to toggle.
    • When an element is collapsed, the height will animate from its current value to zero. Due to how CSS handles animations, padding cannot be applied to a .collapse element.

    Basic example

    A basic collapse works as in the following example. Buttons when clicked show and hide another element via class changes:

    • Class .collapse hides content.
    • Class .collapsing helps transitions.
    • Classes .collapse.show displays content.

    Using a button with the data-bs-target attribute is a good idea. You can also use an <a> link with a role=”button” (although this is not advised from a semantic perspective). data-bs-toggle=”collapse” is necessary in both situations.https://www.tutorialspoint.com/bootstrap/examples/collapse_basic_example.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap plugin - Collapse</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><p><a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
    
          Collapse using link
        &lt;/a&gt;&lt;button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample"&gt;
          Collapse using button
        &lt;/button&gt;&lt;/p&gt;&lt;div class="collapse" id="collapseExample"&gt;&lt;div class="card card-body"&gt;
          The collapse JavaScript plugin used to display and hide content.
        &lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Horizontal

    Horizontal collapsing is supported by collapse plugin. Set a width on the immediate child element and add the .collapse-horizontal modifier class to transition the width rather than the height. You can further customize by using width utilities, create your own unique Sass, or use inline styles.https://www.tutorialspoint.com/bootstrap/examples/collapse_horizontal.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap plugin - Collapse</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><p><button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseWidthExample" aria-expanded="false" aria-controls="collapseWidthExample">
    
        Collapse With Toggle Width 
      &lt;/button&gt;&lt;/p&gt;&lt;div style="min-height: 120px;"&gt;&lt;div class="collapse collapse-horizontal" id="collapseWidthExample"&gt;&lt;div class="card card-body" style="width: 300px;"&gt;
          The collapse plugin supports horizontal collapsing.
        &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Multiple toggles and targets

    Multiple targets can be used to toggle multiple elements assingning them to a common group and using a single <button> or <a> tag to hide/show. Following points helps us understand this better:

    • By assigning the common class in the data-bs-target attribute of the <button> or <a>, an element can reference multiple elements to show and hide them.
    • Multiple <button> or <a> elements can show and hide the same element if they each reference it with their data-bs-target or href attribute.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap plugin - Collapse</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><p><a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Collapse First Item</a><button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Collapse Second Item</button><button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Collapse Both Elements</button></p><div class="row"><div class="col"><div class="collapse multi-collapse" id="multiCollapseExample1"><div class="card card-body">
    
              Example of multiple collpase and targets.
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="col"&gt;&lt;div class="collapse multi-collapse" id="multiCollapseExample2"&gt;&lt;div class="card card-body"&gt;
              Example of multiple collapse and targets.
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Accessibility

    • Use aria-expanded to communicate collapsible element's status to assistive technology. Set aria-expanded="false" for closed collapsible elements and aria-expanded="true" for open ones.
    • The plugin toggles the attribute on the control based on whether the collapsible element is open or closed. Apply role="button" if the control element's HTML element is not a button.
    • Modern screen readers and similar assistive technologies make use of the data-bs-target attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
  • Close Button

    This chapter will discuss about Bootstrap close button. Close button is used for dismissing content like modals, alerts, and popovers.

    Basic example

    • Use .btn-close for creating a close button. Default styling is customizable.
    • Change Sass variables to change background-image and add text for screen readers using aria-label.
    https://www.tutorialspoint.com/bootstrap/examples/closebutton_basic_example.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Close Button</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-2">
    
        Close Notification
        &lt;button type="button" class="btn-close" aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Disabled state

    • Disable close buttons with disabled attribute. Bootstrap also applies pointer-events: none; and user-select: none; to prevent triggering of hover and active states.
    • The opacity of disabled close buttons is changed.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Close Button</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-2">
    
        Close Notification
        &lt;button type="button" class="btn-close" disabled aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Dark variant

    Take note! The .btn-close-white class is deprecated as of v5.3.0. Use data-bs-theme="dark" for the close button color mode.

    To invert the close button, add data-bs-theme="dark" to .btn-close class or to it's parent elements. The filter property is used to invert the background-image.https://www.tutorialspoint.com/bootstrap/examples/closebutton_dark_variant.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Close Button</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body>
    
        Close Notification
        &lt;button type="button" class="btn-close" data-bs-theme="dark" aria-label="Close"&gt;&lt;/button&gt;&lt;button type="button" class="btn-close" data-bs-theme="dark" disabled aria-label="Close"&gt;&lt;/button&gt;&lt;/body&gt;&lt;/html&gt;</pre>

  • Carousel

    This chapter discusses about the Bootstrap component carousel. The Carousel component in Bootstrap is used to display a rotating set of images or content in a slideshow format.

    Overview

    • The component provides multiple options for customization, including slide transitions, interval timing, and navigation controls.
    • It allows users to easily navigate through the content and is commonly used for showcasing products or featured content on a website.
    • To ensure optimal performance, carousels require manual initialization through the carousel constructor method. If not initialized, certain event listeners (specifically those necessary for touch/swipe support) will remain unregistered until a control or indicator is activated by the user.
    • The carousel with the data-bs-ride=”carousel” attribute is initialized automatically on page load. No need to explicitly initialize such carousels.
    • Bootstrap does not support nested carousels. They can also often cause usability and accessibility challenges.
    • The animation effect of the carousel component depends on the prefers-reduced-motion media query.

    Let us see an example of a basic carousel:https://www.tutorialspoint.com/bootstrap/examples/carousel_create.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel example</h1><div id="carouselExample" class="carousel slide"><center><div class="carousel-inner bg-secondary"><div class="carousel-item active"><p class="text-bg-danger display-6">Slide 1</p><img src="/bootstrap/images/tutimg.png" alt="GFG" width="600" height="300" class="d-block w-50" alt="..."></div><div class="carousel-item"><p class="text-bg-danger display-6">Slide 2</p><img src="/bootstrap/images/profile.jpg" alt="GFG" width="300" height="400" class="d-block w-50" alt="..."></div><div class="carousel-item"><p class="text-bg-danger display-6">Slide 3</p><img src="/bootstrap/images/scenery.jpg" alt="GFG" width="300" height="500" class="d-block w-50" alt="..."></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></center></div></body></html>

    Points to remember:

    • The slide dimensions are not automatically normalized in carousels.
    • You need to use additional utilities or custom styles to size the content in carousels.
    • The previous/next controls and indicators are not explicitly required, as carousels support them. Add and customize the controls as per your requirement.
    • Do not forget to add the .active class to one of the slides, else the carousel will not be visible.
    • Ensure to set a unique id on the .carousel for optional controls, in case you are using multiple carousels on a single page.
    • You must add the data-bs-target attribute to the control and indicator elements or href for links, that matches the id of the .carousel element.

    Indicators

    Indicators can be added along with the previous/next controls, such that the user has the access to jump directly to a specific slide.

    Let us see an example for adding indicators:https://www.tutorialspoint.com/bootstrap/examples/carousel_indicators.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel Indicators</h1><div id="carouselExample" class="carousel slide"><center><div id="carouselExampleIndicators" class="carousel slide bg-secondary"><div class="carousel-indicators text-dark"><button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"><h3>1</h3></button><button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"><h3>2</h3></button><button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"><h3>3</h3></button></div><div class="carousel-inner"><div class="carousel-item active"><img src="/bootstrap/images/scenery.jpg" alt="GFG" width="400" height="300" alt="..."></div><div class="carousel-item"><img src="/bootstrap/images/scenery2.jpg" alt="GFG" width="400" height="300" alt="..."></div><div class="carousel-item"><img src="/bootstrap/images/scenery3.jpg" alt="GFG" width="400" height="300" alt="..."></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></div></center></div></body></html>

    Captions

    Captions can be added to the slides with the .carousel-caption element within any .carousel-item. The caption can be hidden using the class .d-none and can be made visible using the classes .d-{breakpoint}-block.

    Let us see an example for adding captions:https://www.tutorialspoint.com/bootstrap/examples/carousel_captions.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel Captions</h1><div id="carouselExampleCaptions" class="carousel slide bg-secondary"><center><div id="carouselExampleCaptions" class="carousel slide bg-secondary"><div class="carousel-indicators text-dark"><button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"><h3>1</h3></button><button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"><h3>2</h3></button><button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"><h3>3</h3></button></div><div class="carousel-inner"><div class="carousel-item active"><img src="/bootstrap/images/template.jpg" alt="GFG" width="400" height="300" alt="..."><div class="carousel-caption text-white"><h5>Caption for first slide</h5><p>This is the first slide of the carousel component.</p></div></div><div class="carousel-item"><img src="/bootstrap/images/template.jpg" alt="GFG" width="400" height="300" alt="..."><div class="carousel-caption text-white"><h5>Caption for second slide</h5><p>This is the second slide of the carousel component.</p></div></div><div class="carousel-item"><img src="/bootstrap/images/template.jpg" alt="GFG" width="400" height="300" alt="..."><div class="carousel-caption text-white"><h5>Caption for third slide</h5><p>This is the third slide of the carousel component.</p></div></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></div></center></div></body></html>

    Crossfade

    To apply a fade transition to your carousel slides instead of a slide, include .carousel-fade. However, if your carousel content comprises solely text slides, it may be necessary to add .bg-body or utilize custom CSS for appropriate crossfading in .carousel-items.

    Let us see an example:

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel Animation - Fade</h1><div id="carouselExampleFade" class="carousel slide"><center><div id="carouselExampleFade" class="carousel slide carousel-fade bg-secondary"><div class="carousel-inner"><div class="carousel-item active"><img src="/bootstrap/images/template.jpg" alt="GFG" width="600" height="500" alt="..."><div class="carousel-caption text-white"><h2>First slide</h2></div></div><div class="carousel-item"><img src="/bootstrap/images/profile.jpg" alt="GFG" width="600" height="500" alt="..."><div class="carousel-caption text-white"><h2>Second slide</h2></div></div><div class="carousel-item"><img src="/bootstrap/images/tutimg.png" alt="GFG" width="600" height="500" alt="..."><div class="carousel-caption text-white"><h2>Third slide</h2></div></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></div></center></div></body></html>

    Autoplaying carousel

    • The carousels can be made to autoplay on page load by setting the ride option to carousel.
    • While you hover with the mouse, the autoplaying carousels pause automatically. You can control this behavior with the option pause.
    • The carousel will stop cycling when the webpage is not v isible (either the browser window is inactive or minimized). in case of browsers support that support the page visibility API.

    To ensure accessibility, it is advised to steer clear of autoplaying carousels. Should your page contain such a feature, we advise adding a separate button or control to enable explicit pausing or stopping of the carousel.

    Let us see an example for autoplaying carousel:https://www.tutorialspoint.com/bootstrap/examples/carousel_autoplay.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel Autoplaying</h1><center><div id="carouselExampleRide" class="carousel slide bg-secondary" data-bs-ride="carousel"><div class="carousel-inner"><div class="carousel-item active"><img src="/bootstrap/images/tutimg.png" alt="GFG" width="400" height="300" alt="..."><div><p><h3>First slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/profile.jpg" alt="GFG" width="400" height="300" alt="..."><div><p><h3>Second slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/template.jpg" alt="GFG" width="400" height="300" alt="..."><div><p><h3>Third slide</h3></p></div></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleRide" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExampleRide" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></div></center></body></html>

    When the ride option is set to true, instead of carousel, the carousel will not automatically start to cycle on page load. It will start only after the user’s interaction.

    Let us see an example:https://www.tutorialspoint.com/bootstrap/examples/carousel_autoplay_ride.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel Autoplaying on Ride</h1><center><div id="carouselExampleRide" class="carousel slide bg-secondary" data-bs-ride="true"><div class="carousel-inner"><div class="carousel-item active"><img src="/bootstrap/images/scenery.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>First slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/scenery2.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Second slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/scenery3.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Third slide</h3></p></div></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleRide" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExampleRide" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></div></center></body></html>

    Individual .carousel-item interval

    To a .carousel-item add data-bs-interval=”” to change the amount of time to set between automatically cycling to next item.

    Let us see an example:https://www.tutorialspoint.com/bootstrap/examples/carousel_time_interval.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel Autoplay Time Interval</h1><center><div id="carouselExampleInterval" class="carousel slide bg-secondary" data-bs-ride="carousel"><div class="carousel-inner"><div class="carousel-item active" data-bs-interval="2000"><img src="/bootstrap/images/tutimg.png" alt="GFG" width="600" height="500" alt="..."><div><p><h3>First slide</h3></p></div></div><div class="carousel-item" data-bs-interval="2000"><img src="/bootstrap/images/profile.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Second slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/template.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Third slide</h3></p></div></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></div></center></body></html>

    Autoplaying carousel without controls

    Carousel can be played without any controls as well.

    Here is an example:https://www.tutorialspoint.com/bootstrap/examples/carousel_without_control.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel Autoplay without controls</h1><center><div id="carouselExampleSlideOnly" class="carousel slide bg-secondary" data-bs-ride="carousel"><div class="carousel-inner"><div class="carousel-item active" data-bs-interval="2000"><img src="/bootstrap/images/tutimg.png" alt="GFG" width="600" height="500" alt="..."><div><p><h3>First slide</h3></p></div></div><div class="carousel-item" data-bs-interval="2000"><img src="/bootstrap/images/profile.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Second slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/template.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Third slide</h3></p></div></div></div></div></center></body></html>

    Disable touch swiping

    Touchscreen devices can swipe left or right to switch between slides on carousels. Turning off the touch option can disable this feature, by setting the value as false.

    Let us see an example:https://www.tutorialspoint.com/bootstrap/examples/carousel_disable_touch.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Carousel</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Carousel disable touch swiping</h1><center><div id="carouselExampleControlsNoTouching" class="carousel slide bg-secondary" data-bs-touch="false"><div class="carousel-inner"><div class="carousel-item active"><img src="/bootstrap/images/profile.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>First slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/template.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Second slide</h3></p></div></div><div class="carousel-item"><img src="/bootstrap/images/profile.jpg" alt="GFG" width="600" height="500" alt="..."><div><p><h3>Third slide</h3></p></div></div></div><button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControlsNoTouching" data-bs-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="visually-hidden">Previous</span></button><button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControlsNoTouching" data-bs-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="visually-hidden">Next</span></button></div></center></body></html>

    Dark variant

    Attention! The use of dark variants for components has been deprecated in v5.3.0 due to the implementation of color modes. Rather than adding .carousel-dark, set data-bs-theme=”dark” on the root element, a parent wrapper, or the component itself.

  • Card

    This chapter will discuss about Bootstrap cards. Bootstrap cards provide flexible and extensible content containers with many flavors and options. A card is a flexible and extensible container for content. It includes header and footer options, different content, contextual background colors, and effective display options.

    Basic card

    • To create a basic card use the class .card. Use spacing utilities when required because cards don’t come with margins.
    • The basic card with mixed content and a fixed width is demonstrated here. Cards naturally cover the entire width of their parent element since they have no fixed width. With many sizing choices, this is easily customizable.
    https://www.tutorialspoint.com/bootstrap/examples/card_basic_card.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 15rem;"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5>A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><a href="#" class="btn btn-primary">Get More information</a></div></div></body></html>

    Content types

    Cards support a various type of content including images, text, list groups, and links. Below are examples of what’s supported.

    Body

    Add the class .card-body whenever you require a padded section within a card.https://www.tutorialspoint.com/bootstrap/examples/card_body.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card"><div class="card-body">
    
          Card body section.
        &lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Titles, text, and links

    • Use the card title by adding the class .card-title to the <h*> tag. You can similarly add and tile links by adding .card-link to the <a> tag.
    • Placing the .card-title and .card-subtitle elements in the .card-body element ensures that the card title and subtitle line up nicely. Subtitles are used by adding .card-subtitle to the <h*> tag.
    https://www.tutorialspoint.com/bootstrap/examples/card_title_text_links.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 18rem;"><div class="card-body"><h5 class="card-title">Mr. Jhon</h5><h6 class="card-subtitle mb-2 text-body-secondary">HR</h6><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><a href="#" class="card-link">More info</a></div></div></body></html>

    Images

    • The class .card-img-top places the image above the card.
    • You can add text to the card using .card-text. The text within .card-text can also be styled using standard HTML tags.
    https://www.tutorialspoint.com/bootstrap/examples/card_images.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 18rem;"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></body></html>

    List groups

    Use flush list groups to create content lists on cards. Add the class .list-group-flush.https://www.tutorialspoint.com/bootstrap/examples/card_list_groups_using_flush.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 18rem;"><ul class="list-group list-group-flush"><li class="list-group-item">Item 1</li><li class="list-group-item">Item 2</li><li class="list-group-item">Item 3</li></ul></div></body></html>

    Use flush list groups to create header content lists on cards. Add the header to the list group of card by adding the class .card-header.https://www.tutorialspoint.com/bootstrap/examples/card_list_groups_header_using_flush.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 18rem;"><div class="card-header">
    
          Header
      &lt;/div&gt;&lt;ul class="list-group list-group-flush"&gt;&lt;li class="list-group-item"&gt;Item 1&lt;/li&gt;&lt;li class="list-group-item"&gt;Item 2&lt;/li&gt;&lt;li class="list-group-item"&gt;Item 3&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Use flush list groups to create footer content lists on cards. Add the footer to the list group of card by adding the class .card-footer.https://www.tutorialspoint.com/bootstrap/examples/card_list_groups_footer_using_flush.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 18rem;"><ul class="list-group list-group-flush"><li class="list-group-item">Item 1</li><li class="list-group-item">Item 2</li><li class="list-group-item">Item 3</li></ul><div class="card-footer">
    
        Card Footer
      &lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Kitchen sink

    Combine multiple content types to create the card you want, or populate it all. Below are image styles, blocks, text styles, and list groups, all grouped into fixed-width card.https://www.tutorialspoint.com/bootstrap/examples/card_kitchen_sink.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 18rem;"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><ul class="list-group list-group-flush"><li class="list-group-item">Item 1</li><li class="list-group-item">Item 2</li><li class="list-group-item">Item 3</li></ul><div class="card-body"><a href="#" class="card-link">Link  1</a><a href="#" class="card-link">Link 2</a></div></div></body></html>

    Header and footer

    Include an optional header and/or footer inside a card.https://www.tutorialspoint.com/bootstrap/examples/card_header.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card"><div class="card-header">
    
        Card Header
      &lt;/div&gt;&lt;div class="card-body"&gt;&lt;h5 class="card-title"&gt;Card Title&lt;/h5&gt;&lt;p class="card-text"&gt;A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.&lt;/p&gt;&lt;a href="#" class="btn btn-primary"&gt;Get more info&lt;/a&gt;&lt;/div&gt;&lt;div class="card-footer"&gt;
         Card Footer
      &lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    You can style the card header by adding .card-header to the <h*> element.https://www.tutorialspoint.com/bootstrap/examples/card_header_using_h.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card"><h5 class="card-header">Card Header</h5><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><a href="#" class="btn btn-primary">Get more info</a></div></div></body></html>

    To highlight, add the class .blockquote mb-0 to the .blockquote.https://www.tutorialspoint.com/bootstrap/examples/card_header_using_quote.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card"><div class="card-header">
    
      Quote
    &lt;/div&gt;&lt;div class="card-body"&gt;&lt;blockquote class="blockquote mb-0"&gt;&lt;p&gt;blockquote element&lt;/p&gt;&lt;footer class="blockquote-footer"&gt;Blockquote footer &lt;cite title="Source Title"&gt;Source Title&lt;/cite&gt;&lt;/footer&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Align the text of whole card at the center with the class .text-center.https://www.tutorialspoint.com/bootstrap/examples/card_header_text_in_center.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card text-center"><div class="card-header">
    
        Rose
      &lt;/div&gt;&lt;div class="card-body"&gt;&lt;h5 class="card-title"&gt;A rose is a flower that people in love give each other.&lt;/h5&gt;&lt;p class="card-text"&gt;Roses have multi-layered petals and smell wonderfully sweet. They come in a wide variety of colors that can convey various meanings.&lt;/p&gt;&lt;a href="#" class="btn btn-primary"&gt;More info&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Sizing

    Card width is 100% unless otherwise stated. This can be customized using custom CSS, grid classes, grid sass mixins, or utilities.

    Using grid markup

    Use a grid to wrap your cards into columns and rows as required.https://www.tutorialspoint.com/bootstrap/examples/card_sizing_grid_markup.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="row"><div class="col-sm-6 mb-3 mb-sm-0"><div class="card"><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><a href="#" class="btn btn-primary">Get more info</a></div></div></div><div class="col-sm-6"><div class="card"><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><a href="#" class="btn btn-primary">Get more info</a></div></div></div></div></body></html>

    Using utilities

    Quickly set the width of your card using some of the available resizing utilities.https://www.tutorialspoint.com/bootstrap/examples/card_using_utilities.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card w-75 mb-3"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content..</p><a href="#" class="btn btn-primary">Card Button</a></div></div><div class="card w-50"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><a href="#" class="btn btn-primary">Card Button</a></div></div></body></html>

    Using custom CSS

    Use custom CSS in your style sheet or as an inline style to set the width.https://www.tutorialspoint.com/bootstrap/examples/card_using_custom_css.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card" style="width: 18rem;"><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><a href="#" class="btn btn-primary">Get more info</a></div></div></body></html>

    Text alignment

    Text Alignment classes allow you to quickly change the text alignment of the entire card or specific parts.https://www.tutorialspoint.com/bootstrap/examples/card_text_alignment.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card mb-3" style="width: 18rem;"><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">The text alignment of the card at the left.</p><a href="#" class="btn btn-primary">Get more info</a></div></div><div class="card text-center mb-3" style="width: 18rem;"><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">The text alignment of the card at the center.</p><a href="#" class="btn btn-primary">Get more info</a></div></div><div class="card text-end" style="width: 18rem;"><div class="card-body"><h5 class="card-title">Card Title</h5><p class="card-text">The text alignment of the card at the right.</p><a href="#" class="btn btn-primary">Get more info</a></div></div></body></html>

    Navigation

    Add navigation to the header (or block) of your card using Bootstrap navigation components.https://www.tutorialspoint.com/bootstrap/examples/card_navigation.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card text-center"><div class="card-header"><ul class="nav nav-tabs card-header-tabs"><li class="nav-item"><a class="nav-link active" aria-current="true" href="#">Home</a></li><li class="nav-item"><a class="nav-link" href="#">Services</a></li><li class="nav-item"><a class="nav-link disabled">About us</a></li></ul></div><div class="card-body"><h5 class="card-title">Rose</h5><p class="card-text">Roses have multi-layered petals and smell wonderfully sweet. They come in a wide variety of colors that can convey various meanings.</p><a href="#" class="btn btn-primary">Get more info</a></div></div></body></html>

    Get the Bootstrap navigation components by adding the class .nav-pills.https://www.tutorialspoint.com/bootstrap/examples/card_navigation_using_pills.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card text-center"><div class="card-header"><ul class="nav nav-pills card-header-pills"><li class="nav-item"><a class="nav-link active" href="#" >Home</a></li><li class="nav-item"><a class="nav-link" href="#">Services</a></li><li class="nav-item"><a class="nav-link disabled">About us</a></li></ul></div><div class="card-body"><h5 class="card-title">Rose</h5><p class="card-text">Roses have multi-layered petals and smell wonderfully sweet. They come in a wide variety of colors that can convey various meanings.</p><a href="#" class="btn btn-primary">Get more info</a></div></div></body></html>

    Images

    Cards contain several options for working with images. Choose to have "image caps" on each side of the card, overlay the image on the card's contents, or simply embed the image into the card.

    Image caps

    Cards can have "image caps" at top and bottom (images at the top or bottom of the card), similar to headers and footers as demonstrated below.https://www.tutorialspoint.com/bootstrap/examples/card_images_caps.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card mb-3"><img src="\bootstrap\images\tutimg2.jpg" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><p class="card-text"><small class="text-body-secondary">2 mins ago</small></p></div></div><div class="card"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><p class="card-text"><small class="text-body-secondary">5 mins ago</small></p></div><img src="\bootstrap\images\tutimg2.jpg" class="card-img-bottom" alt="..."></div></body></html>

    Images overlays

    Turn an image into a card background and overlay the card text. Some images may require additional styling or utility.https://www.tutorialspoint.com/bootstrap/examples/card_images_overlays.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card text-bg-dark"><img src="\bootstrap\images\tutimg2.jpg" class="card-img" alt="..."><div class="card-img-overlay"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><p class="card-text"><small>2 mins ago</small></p></div></div></body></html>

    Note: It is important note that text/content should not exceed the height of the image, as this will cause it to be displayed outside the frame.

    Horizontal

    By using a combination of grid and utility classes, you can create cards horizontally in a mobile-friendly and responsive way. In the example below, .g-0 removes the grid bars and uses the .col-md-* classes to level the card at the md breakpoints.https://www.tutorialspoint.com/bootstrap/examples/card_horizontal.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card mb-3" style="max-width: 540px;"><div class="row g-0"><div class="col-md-4"><img src="\bootstrap\images\tutimg.png" class="img-fluid rounded-start" alt="..."></div><div class="col-md-8"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><p class="card-text"><small class="text-body-secondary">1 mins ago</small></p></div></div></div></div></body></html>

    Card styles

    A wide range of background, border, and color customization choices are available for cards.

    Background and color

    Added in v5.2.0

    • Using .text-bg-{color} helpers, you can set a background color with a contrasting foreground color.
    • Previously, pairing .text-color and .bg-color utilities manually was necessary for styling, you can still do so if you prefer.
    https://www.tutorialspoint.com/bootstrap/examples/card_background_and_color.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card text-bg-primary mb-3" style="max-width: 18rem;"><div class="card-header">Primary</div><div class="card-body"><p class="card-text">A card with primary background-color.</p></div></div><div class="card text-bg-secondary mb-3" style="max-width: 18rem;"><div class="card-header">Secondary</div><div class="card-body"><p class="card-text">A card with secondary background-color.</p></div></div><div class="card text-bg-success mb-3" style="max-width: 18rem;"><div class="card-header">Success</div><div class="card-body"><p class="card-text">A card with success background-color.</p></div></div><div class="card text-bg-danger mb-3" style="max-width: 18rem;"><div class="card-header">Danger</div><div class="card-body"><p class="card-text">A card with danger background-color.</p></div></div><div class="card text-bg-warning mb-3" style="max-width: 18rem;"><div class="card-header">Warning</div><div class="card-body"><p class="card-text">A card with warning background-color.</p></div></div><div class="card text-bg-info mb-3" style="max-width: 18rem;"><div class="card-header">Info</div><div class="card-body"><p class="card-text">A card with info background-color.</p></div></div><div class="card text-bg-light mb-3" style="max-width: 18rem;"><div class="card-header">light</div><div class="card-body"><p class="card-text">A card with light background-color.</p></div></div><div class="card text-bg-dark mb-3" style="max-width: 18rem;"><div class="card-header">Dark</div><div class="card-body"><p class="card-text">A card with dark background-color.</p></div></div></body></html>

    Border

    By using the border utilities you can change the card border-color. Note that the .text-{color} class can be placed on the parent .card or a subset of the card's content as shown below.https://www.tutorialspoint.com/bootstrap/examples/card_border.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card border-primary mb-3" style="max-width: 18rem;"><div class="card-header">Primary</div><div class="card-body text-primary"><p class="card-text">A card with primary border-color.</p></div></div><div class="card border-dark mb-3" style="max-width: 18rem;"><div class="card-header">Dark</div><div class="card-body"><p class="card-text">A card with dark border-color.</p></div></div><div class="card border-secondary mb-3" style="max-width: 18rem;"><div class="card-header">Secondary</div><div class="card-body text-secondary"><p class="card-text">A card with secondary border-color.</p></div></div><div class="card border-light mb-3" style="max-width: 18rem;"><div class="card-header">Light</div><div class="card-body"><p class="card-text">A card with light border-color.</p></div></div><div class="card border-danger mb-3" style="max-width: 18rem;"><div class="card-header">Danger</div><div class="card-body text-danger"><p class="card-text">A card with light border-color.</p></div></div><div class="card border-warning mb-3" style="max-width: 18rem;"><div class="card-header">Warning</div><div class="card-body"><p class="card-text">A card with warning border-color.</p></div></div><div class="card border-success mb-3" style="max-width: 18rem;"><div class="card-header">Success</div><div class="card-body text-success"><p class="card-text">A card with success  border-color.</p></div></div><div class="card border-info mb-3" style="max-width: 18rem;"><div class="card-header">Info</div><div class="card-body"><p class="card-text">A card with info border-color.</p></div></div></body></html>

    Mixins utilities

    You can also change the card header and footer borders and remove the background color with .bg-transparent if you like.https://www.tutorialspoint.com/bootstrap/examples/card_mixins_utilities.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card border-info mb-3" style="max-width: 18rem;"><div class="card-header bg-transparent border-info">Card Header</div><div class="card-body text-info"><h5 class="card-title">Info card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><div class="card-footer bg-transparent border-info">Card Footer</div></div></body></html>

    Card layout

    In addition to styling and customising the content in your card, Bootstrap provides several options for arranging card in series. Currently, these layout options are not responsive. Following sections demonstrates this.

    Card groups

    Card groups render cards as a single attached element with columns of the same width and height. Card groups are stacked. They use display: flex; to become attached with uniform dimensions starting at the sm breakpoint.https://www.tutorialspoint.com/bootstrap/examples/card_layout_card_groups.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card-group"><div class="card"><img src="\bootstrap\images\tutimg2.jpg" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><p class="card-text"><small class="text-body-secondary">1 mins ago</small></p></div></div><div class="card"><img src="\bootstrap\images\tutimg2.jpg" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><p class="card-text"><small class="text-body-secondary">2 mins ago</small></p></div></div><div class="card"><img src="\bootstrap\images\tutimg2.jpg" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p><p class="card-text"><small class="text-body-secondary">3 mins ago</small></p></div></div></div></body></html>

    Use a card group with a footer, its content is automatically arranged.https://www.tutorialspoint.com/bootstrap/examples/card_layout_card_groups_footer.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="card-group"><div class="card"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><div class="card-footer"><small class="text-body-secondary">1 mins ago</small></div></div><div class="card"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><div class="card-footer"><small class="text-body-secondary">2 mins ago</small></div></div><div class="card"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><div class="card-footer"><small class="text-body-secondary">3 mins ago</small></div></div></div></body></html>

    Grid cards

    • Use the Bootstrap grid system and its .row-cols class to control the number of grid columns (wrapped around the cards) to display per row.
    • For example, here's .row-cols-1 to put cards in columns and .row-cols-md-2 to spread 4 cards of the same width across multiple rows from the middle breakpoint upwards.
    https://www.tutorialspoint.com/bootstrap/examples/card_grid_cards.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="row row-cols-1 row-cols-md-2 g-4"><div class="col"><div class="card"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p></div></div></div><div class="col"><div class="card"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card"><img src="\bootstrap\images\tutimg.png" class="card-img-top" alt="..."><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div></div></body></html>

    If you change it to .row-cols-3 you will see the 4th card break.https://www.tutorialspoint.com/bootstrap/examples/card_grid_cards_row_col_3.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="row row-cols-1 row-cols-sm-3 g-5"><div class="col"><div class="card"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content.A card is a flexible and extensible container for content</p></div></div></div><div class="col"><div class="card"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div></div></body></html>

    When you want the same height to add .h-100 to the card. You want the same height by default, you can set $card-height: 100% in Sass.https://www.tutorialspoint.com/bootstrap/examples/card_grid_height_100.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="row row-cols-1 row-cols-sm-3 g-5"><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content.A card is a flexible and extensible container for content</p></div></div></div><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div></div></div></div></body></html>

    Like card groups, card footers are automatically arranged.https://www.tutorialspoint.com/bootstrap/examples/card_group_footer.php

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Card</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="row row-cols-1 row-cols-sm-3 g-4"><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><div class="card-footer"><small class="text-body-secondary">1 mins ago</small></div></div></div><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><div class="card-footer"><small class="text-body-secondary">2 mins ago</small></div></div></div><div class="col"><div class="card h-100"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">A card is a flexible and extensible container for content. A card is a flexible and extensible container for content.</p></div><div class="card-footer"><small class="text-body-secondary">3 mins ago</small></div></div></div></div></body></html>

    Print Page

  • Button Group

    This chapter will discuss about Bootstrap button groups. Bootstrap button group puts multiple buttons together on a single line, horizontally or vertically.

    Basic example

    You can create a group of buttons using .btn in .btn-group class.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group" role="group" aria-label="Basic Example"><button type="button" class="btn btn-info">Register</button><button type="button" class="btn btn-danger">Submit</button><button type="button" class="btn btn-warning">Cancel</button></div></body></html>

    To ensure accessibility for assistive technologies like screen readers, it is important to use the appropriate role attribute and provide explicit labels for button groups. You can use role=”group” for button groups or role=”toolbar” for button toolbars. To label them, you can use aria-label or aria-labelledby.

    • As an alternative to the .nav navigation components, these classes can also be applied to groups of links.
    • You can highlight a link by using .active class.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group my-2"><a href="#" class="btn btn-success active" aria-current="page">Registration Link</a><a href="#" class="btn btn-success">Submit</a><a href="#" class="btn btn-success">Cancel</a></div></body></html>

    Mixed styles

    In the case of button groups mixed styles, it is possible to form a button group where each button has a distinct background color.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group mt-2" role="group" aria-label="Mixed styles"><button type="button" class="btn btn-info">Register</button><button type="button" class="btn btn-success">Cancel</button><button type="button" class="btn btn-warning">Submit</button></div></body></html>

    Outlined styles

    Use button styles such as btn-outline-primarybtn-outline-dark, etc to show the colors only for the border of the buttons element in the group.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group my-2" role="group" aria-label="Basic outlined"><button type="button" class="btn btn-outline-primary">Register</button><button type="button" class="btn btn-outline-dark">Submit</button><button type="button" class="btn btn-outline-warning">Cancel</button></div></body></html>

    Checkbox and radio button groups

    Using button like-checkbox toggle buttons, we can create seamless looking button group. To acheive this use .btn-check class and type=”checkbox”.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group my-2" role="group" aria-label="checkbox toggle button group"><input type="checkbox" class="btn-check" id="btnCheckbox1" autocomplete="off"><label class="btn btn-outline-primary" for="btnCheckbox1">Register</label><input type="checkbox" class="btn-check" id="btnCheckbox2" autocomplete="off"><label class="btn btn-outline-warning" for="btnCheckbox2">Submit</label><input type="checkbox" class="btn-check" id="btnCheckbox3" autocomplete="off"><label class="btn btn-outline-info" for="btnCheckbox3">Cancel</label></div></body></html>

    Using button like-radio toggle button, we can create a seamless looking button group. To aceive this use .btn-check and type=”radio”.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group" role="group" aria-label="radio toggle button group"><input type="radio" class="btn-check" name="radioButton" id="buttonRadio1" autocomplete="off" checked><label class="btn btn-outline-primary" for="buttonRadio1">Register</label><input type="radio" class="btn-check" name="radioButton" id="buttonRadio2" autocomplete="off"><label class="btn btn-outline-warning" for="buttonRadio2">Submit</label><input type="radio" class="btn-check" name="radioButton" id="buttonRadio3" autocomplete="off"><label class="btn btn-outline-success" for="buttonRadio3">Cancel</label></div></body></html>

    Button toolbar

    Button toolbars can be created by combining sets of button groups. Use utility classes to add a space between groups, buttons, etc.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-toolbar mt-2" role="toolbar" aria-label="Toolbar button groups"><div class="btn-group me-2" role="group" aria-label="toolbarButtonGroup1"><button type="button" class="btn btn-primary">Primary</button><button type="button" class="btn btn-info">Info</button><button type="button" class="btn btn-secondary">Secondary</button></div><div class="btn-group me-2" role="group" aria-label="toolbarButtonGroup2"><button type="button" class="btn btn-success">Success</button><button type="button" class="btn btn-dark">Dark</button></div><div class="btn-group" role="group" aria-label="toolbarButtonGroup3"><button type="button" class="btn btn-warning">Warning</button></div></div></body></html>

    Combine input groups and button groups in toolbars. Space things appropriately using utilities.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-toolbar mb-3" role="toolbar" aria-label="toolbarButtonGroup1"><div class="btn-group me-2" role="group" aria-label="toolbarButtonGroup2"><button type="button" class="btn btn-outline-primary">Primary</button><button type="button" class="btn btn-outline-info">Info</button><button type="button" class="btn btn-outline-secondary">secondary</button></div><div class="input-group"><div class="input-group-text" id="inputbtnGroup1">@</div><input type="text" class="form-control" placeholder="Username" aria-label="toolbarButtonGroup3" aria-describedby="inputButtonGroup1"></div></div><div class="btn-toolbar justify-content-between" role="toolbar" aria-label="toolbarButtonGroup4"><div class="btn-group" role="group" aria-label="toolbarButtonGroup1"><button type="button" class="btn btn-outline-warning">Warning</button><button type="button" class="btn btn-outline-success">Success</button></div><div class="input-group"><input type="text" class="form-control" placeholder="tutorialspoint" aria-label="toolbarButtonGroup5" aria-describedby="inputButtonGroup2"><div class="input-group-text" id="inputbtnGroup2">@example.com</div></div></div></body></html>

    Sizing

    When nesting several groups, use .btn-group-* on each .btn-group rather than button sizing classes for each button.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h6 class="mt-4">Default size button group</h6><div class="btn-group" role="group" aria-label="Default size button group"><button type="button" class="btn btn-outline-dark">Dark</button><button type="button" class="btn btn-outline-warning">Warning</button></div><h6 class="mt-4">Small size button group</h6><div class="btn-group btn-group-sm" role="group" aria-label="Small size button group"><button type="button" class="btn btn-outline-secondary">Secondary</button><button type="button" class="btn btn-outline-success">Success</button></div><h6 class="mt-4">Large size button group</h6><div class="btn-group btn-group-lg" role="group" aria-label="Large size button group"><button type="button" class="btn btn-outline-primary">Primary</button><button type="button" class="btn btn-outline-info">Info</button></div></body></html>

    Nesting

    To get the dropdown menu mixed with button series, use .btn-group within another .btn-group.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group mt-2" role="group" aria-label="Nested dropdown"><button type="button" class="btn btn-primary">Submit</button><button type="button" class="btn btn-warning">Cancel</button><div class="btn-group" role="group"><button type="button" class="btn btn-info dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    
          Languages
        &lt;/button&gt;&lt;ul class="dropdown-menu"&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;English&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Hindi&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Vertical variation

    To create vertically stacked button group, use .btn-group-vertical class. Bootstrap doesn't support split button dropdowns in this case.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group-vertical mt-2" role="group" aria-label="Button group with verical variation"><button type="button" class="btn btn-primary">Primary</button><button type="button" class="btn btn-warning">Warning</button><button type="button" class="btn btn-info">Info</button></div></body></html>

    Create the vertical button group with the dropdown menu.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group-vertical mt-2" role="group" aria-label="Vertical button group"><button type="button" class="btn btn-primary">Primary</button><button type="button" class="btn btn-info">Secondary</button><div class="btn-group" role="group"><button type="button" class="btn btn-warning dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    
          Languages
        &lt;/button&gt;&lt;ul class="dropdown-menu"&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;English&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;French&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;button type="button" class="btn btn-success"&gt;Success&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Create vertical button group with radio buttons.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Button Groups</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="btn-group-vertical mt-2" role="group" aria-label="Vertical button group with radio"><input type="radio" class="btn-check" name="vbtn-radio" id="verticalRadioButton1" autocomplete="off" ><label class="btn btn-outline-warning" for="verticalRadioButton1">Unchecked Radio Button</label><input type="radio" class="btn-check" name="vbtn-radio" id="verticalRadioButton2" autocomplete="off" checked><label class="btn btn-outline-warning" for="verticalRadioButton2">checked Radio Button</label><input type="radio" class="btn-check" name="vbtn-radio" id="verticalRadioButton3" autocomplete="off"><label class="btn btn-outline-warning" for="verticalRadioButton3">Unchecked Radio Button</label></div></body></html>

  • Breadcrumb

    This chapter will discuss about Bootstrap breadcrumbs. A breadcrumb is a navigational method that shows the user where they are relative to the current page on a website or application. An accessible website with many pages or a complicated hierarchy can benefit greatly from breadcrumb navigation.

    Basic breadcrumbs

    Bootstrap allows users to easily create static breadcrumbs layouts by adding the class .breadcrumb to ordered or unordered lists, as demonstrated in the following example. Utility classes can be used to decorate the breadcrumbs.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Breadcrumb</title></head><body><div class="m-4"><nav aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item active" aria-current="page">Home</li></ol></nav><nav aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="#">Home</a></li><li class="breadcrumb-item active" aria-current="page">Services</li></ol></nav><nav aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="#">Home</a></li><li class="breadcrumb-item"><a href="#">Services</a></li><li class="breadcrumb-item active" aria-current="page">Contact</li></ol></nav></div></body></html>

    Dividers

    When you want to modify the default breadcrumb divider / with the > as a divider, then you can use some custom CSS style rules as shown in the below example:

    Dividers are automatically added in CSS through the pseudo-element ::before and property content.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Breadcrumb</title></head><body><div class="m-4"><nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="#">Home</a></li><li class="breadcrumb-item active" aria-current="page">Services</li></ol></nav></div></body></html>

    The quote function is required to quote strings when modifying with Sass. For example, if you use > as your delimiter, then you can use $breadcrumb-divider: quote(“>”);

    You can also use embedded SVG icons. Apply icons via custom CSS properties or use Sass variables as demonstrated below.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Breadcrumb</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body>
    
      &lt;nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='%236c757d'/%3E%3C/svg%3E");" aria-label="breadcrumb"&gt;
          &lt;ol class="breadcrumb"&gt;&lt;li class="breadcrumb-item"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;&lt;li class="breadcrumb-item active" aria-current="page"&gt;About us&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    If you don't want a breadcrumb separator into the linked list items then set the value of --bs-breadcrumb-divider as a empty strings (' ') or set a Saas variable to $breadcrumb-divider: none;

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Breadcrumb</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><nav style="--bs-breadcrumb-divider: '';" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="#">Home</a></li><li class="breadcrumb-item active" aria-current="page">About us</li></ol></nav></body></html>

  • Badges

    This chapter will discuss about bootstrap badges and the classes to create badges. Badges are frequently used for highlighting important details on web pages, such as headings, warnings, and notification counters.

    Bootstrap badges are numerical indication or notification counters (of how many items are associated with a link).

    Badges

    To scale them according to the size of the immediate parent element, badge uses comparative font scaling and em units. In page links, focus or hover styles are no longer supported as of version 5.

    Following example demonstrates how to create inline badges using Bootstrap.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Badges</title></head><body><h1>Sample heading <span class="badge bg-secondary">New</span></h1><h2>Sample heading <span class="badge bg-secondary">Offer</span></h2><h3>Sample heading <span class="badge bg-secondary">New</span></h3><h4>Sample heading <span class="badge bg-secondary">Offer</span></h4><h5>Sample heading <span class="badge bg-secondary">New</span></h5><h6>Sample heading <span class="badge bg-secondary">Offer</span></h6></body></html>

    Buttons

    Badges can be used as part of links or buttons to provide a counter. The users will only see the content of the badge because of how badges are styled, which gives a visual cue as to their purpose. These badges may appear to be random additions of words or numbers at the conclusion of a sentence, a link, or a button, based on the circumstances.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Badges</title></head><body><button type="button" class="btn btn-success" style="margin: 20px;">
    
      Messages &lt;span class="badge text-bg-warning"&gt;6&lt;/span&gt;&lt;/button&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Notifications

    This example explains a visually hidden class with a portion of additional text where users can see the digit "32" represents the number of notifications.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Badges</title></head><body><button type="button" class="btn btn-success position-relative" style="margin: 20px;">
    
    Notifications
    &lt;span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-primary"&gt;
      32+
      &lt;span class="visually-hidden"&gt;unread notifications&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Positioned

    .badge can be modified with top-0 start-100 translate-middle utilities and placed in the corner of a link or button. Let's look at the sample below to see how it generally functions.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Badges</title></head><body><button type="button" class="btn btn-primary position-relative" style="margin: 20px;">
    
    Inbox
    &lt;span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-info"&gt;
      55+
      &lt;span class="visually-hidden"&gt;unread notifications&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Indicator

    Bootstrap Badges are a numerical indication of the number of items associated with a link. Items that are new or unread are highlighted using badges

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Badges</title></head><body><button type="button" class="btn btn-info position-relative" style="margin: 20px;">
    
    Webinar
    &lt;span class="position-absolute top-0 start-100 translate-middle p-2 bg-primary border border-light rounded-circle"&gt;&lt;span class="visually-hidden"&gt;New notifications&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Background colors

    Using the .text-bg-{color} helpers , users may set a background color with a contrasting foreground color. In the past, pairing the preferred .text-{color} and .bg-{color} utilities manually was necessary for styling; nevertheless, users are still free to do so if they wish.

    Use the text-bg-primarytext-bg-infotext-bg-success etc. utility classes offered by bootstrap's background colour framework to instantly change the appearance of the badges.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Badges</title></head><body style="margin: 20px;"><span class="badge text-bg-primary">Primary</span><span class="badge text-bg-info">Info</span><span class="badge text-bg-secondary">Secondary</span><span class="badge text-bg-success">Success</span><span class="badge text-bg-light">Light</span><span class="badge text-bg-dark">Dark</span><span class="badge text-bg-warning">Warning</span><span class="badge text-bg-danger">Danger</span></body></html>

    Pill Badges

    Users can design badges in the shape of pills, or badges having more rounded corners, by using the .rounded-pill modifier class, as demonstrated in the example below.

    To quickly modify the appearance of the badges, use the .rounded-pill utility classes provided in bootstrap's background color framework.

    Example

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><title>Bootstrap - Badges</title></head><body style="margin: 20px;"><span class="badge rounded-pill text-bg-primary">Primary</span><span class="badge rounded-pill text-bg-secondary">Secondary</span><span class="badge rounded-pill text-bg-info">Info</span><span class="badge rounded-pill text-bg-success">Success</span><span class="badge rounded-pill text-bg-light">Light</span><span class="badge rounded-pill text-bg-dark">Dark</span><span class="badge rounded-pill text-bg-danger">Danger</span><span class="badge rounded-pill text-bg-warning">Warning</span></body></html>

  • Alerts

    This chapter discusses about the Bootstrap alerts. The alert messages are often the stand out messages shown to the user, where some user action is required, such as warning, error, information or confirmation messages.

    By extending the .alert base class with the contextual classes (such as .alert-success, .alert-warning, .alert-info, etc.), you can quickly and simply build attractive alert messages for any number of reasons using Bootstrap. To cancel any alert, you may also include an optional close button.

    Simple Alerts

    There is a total of 8 different alert types offered by Bootstrap. The most typical alerts, such as success, error or danger, warning and info alerts, etc., are demonstrated in the example below.

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Alerts</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-3"><h4 class="fs-2">Examples of alert messages</h4><div class="alert alert-primary" role="alert">
    
                It is a primary alert box!
            &lt;/div&gt;&lt;div class="alert alert-secondary" role="alert"&gt;
                It is a secondary alert box!
            &lt;/div&gt;&lt;div class="alert alert-success" role="alert"&gt;
                It is a success alert box!
            &lt;/div&gt;&lt;div class="alert alert-danger" role="alert"&gt;
                It is a danger alert box!
            &lt;/div&gt;&lt;div class="alert alert-warning" role="alert"&gt;
                It is a warning alert box!
            &lt;/div&gt;&lt;div class="alert alert-info" role="alert"&gt;
                It is an info alert box!
            &lt;/div&gt;&lt;div class="alert alert-light" role="alert"&gt;
                It is a light alert box!
            &lt;/div&gt;&lt;div class="alert alert-dark" role="alert"&gt;
                It is a dark alert box!
            &lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Accessibility tip: Use of color to the alert messages just provides a visual indication, and this will not be helpful to users of assistive technologies like screen readers. Make sure that the meaning is clear from the content itself.

    Use alternative means to add clarity to the content using the .visually-hidden class.

    Live alert example

    You can add a live alert message on your webpage. In order to achieve this refer the example given below.

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Alerts</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-3"><h4 class="fs-2">Live alert</h4><div class="alert alert-primary alert-dismissible" role="alert"><div id="liveAlertPlaceholder"></div><button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button></div></div><script>
    
                const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
                const appendAlert = (message, type) =&gt; {
                const wrapper = document.createElement('div')
                wrapper.innerHTML = [
                &amp;lt;div class="alert alert-${type} alert-dismissible" role="alert"&amp;gt;,
                   &amp;lt;div&amp;gt;${message}&amp;lt;/div&amp;gt;,
                '   &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;',
                '&lt;/div&gt;'
                ].join('')
                alertPlaceholder.append(wrapper)
                }
                const alertTrigger = document.getElementById('liveAlertBtn')
                if (alertTrigger) {
                    alertTrigger.addEventListener('click', () =&gt; {
                    appendAlert('Amazing, this is a live alert message!', 'success')
                    })
                    }
            &lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    The following Javascript is used to trigger the live alert demo:

      const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
    
            const appendAlert = (message, type) =&gt; {
            const wrapper = document.createElement('div')
            wrapper.innerHTML = [
            ``,
               ${message},
            '   ',
            ''
            ].join('')
              alertPlaceholder.append(wrapper)
            }
            const alertTrigger = document.getElementById('liveAlertBtn')
            if (alertTrigger) {
                alertTrigger.addEventListener('click', () =&gt; {
                appendAlert('Amazing, this is a live alert message!', 'success')
                 })
                }

    Link Color

    The utility class .alert-link can be used for any alert message to instantly produce matching coloured links, as demonstrated in the example below.

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Alerts</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-3"><h4 class="fs-2">Alert messages with links</h4><div class="alert alert-primary" role="alert">
    
                It is a primary alert with &lt;a href="https://www.tutorialspoint.com/bootstrap/bootstrap_alerts.htm" class="alert-link"&gt;tutorialspoint.com&lt;/a&gt;&lt;/div&gt;&lt;div class="alert alert-secondary" role="alert"&gt;
                It is a secondary alert with &lt;a href="https://www.tutorialspoint.com/bootstrap/bootstrap_alerts.htm" class="alert-link"&gt;tutorialspoint.com&lt;/a&gt;&lt;/div&gt;&lt;div class="alert alert-success" role="alert"&gt;
                It is a success alert with &lt;a href="https://www.tutorialspoint.com/bootstrap/bootstrap_alerts.htm" class="alert-link"&gt;tutorialspoint.com&lt;/a&gt;&lt;/div&gt;&lt;div class="alert alert-danger" role="alert"&gt;
                It is a danger alert with &lt;a href="https://www.tutorialspoint.com/bootstrap/bootstrap_alerts.htm" class="alert-link"&gt;tutorialspoint.com&lt;/a&gt;&lt;/div&gt;&lt;div class="alert alert-warning" role="alert"&gt;
                It is a warning alert with &lt;a href="https://www.tutorialspoint.com/bootstrap/bootstrap_alerts.htm" class="alert-link"&gt;tutorialspoint.com&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Additional content

    Additional HTML elements like headers, paragraphs, and dividers can also be included in alerts. Following example demonstrates the same.

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Alerts</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-3"><h4 class="fs-2">Alert messages with additional content</h4><div class="alert alert-success" role="alert"><h4 class="alert-heading">Congratulations! Sending my best wishes.</h4><p>Congratulations on your graduation! Sending you our best wishes for a happy and successful future.</p><hr><p class="mb-0">What could be better than something sweet to celebrate an accomplishment!!!</p></div></div></body></html>

    Alerts with Icons

    For creating alerts with icons use flexbox utilities and Bootstrap Icons.https://www.tutorialspoint.com/bootstrap/examples/alerts_icon.php

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Alerts</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-3"><h4 class="fs-2">Alert messages with icons</h4><svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="success-bg" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/></symbol><symbol id="info-bg" viewBox="0 0 16 16"><path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/></symbol><symbol id="warning-bg" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></symbol></svg><div class="alert alert-primary d-flex align-items-center" role="alert"><svg class="bi flex-shrink-0 me-2" role="img" aria-label="Info:"><use xlink:href="#info-bg"/></svg><div>
    
                  It is an info alert with an info icon.
                &lt;/div&gt;&lt;/div&gt;&lt;div class="alert alert-success d-flex align-items-center" role="alert"&gt;&lt;svg class="bi flex-shrink-0 me-2" role="img" aria-label="Success:"&gt;&lt;use xlink:href="#success-bg"/&gt;&lt;/svg&gt;&lt;div&gt;
                  It is a success alert with a success icon.
                &lt;/div&gt;&lt;/div&gt;&lt;div class="alert alert-warning d-flex align-items-center" role="alert"&gt;&lt;svg class="bi flex-shrink-0 me-2" role="img" aria-label="Warning:"&gt;&lt;use xlink:href="#warning-bg"/&gt;&lt;/svg&gt;&lt;div&gt;
                  It is a warning alert with a warning icon.
                &lt;/div&gt;&lt;/div&gt;&lt;div class="alert alert-danger d-flex align-items-center" role="alert"&gt;&lt;svg class="bi flex-shrink-0 me-2" role="img" aria-label="Danger:"&gt;&lt;use xlink:href="#warning-bg"/&gt;&lt;/svg&gt;&lt;div&gt;
                  It is a danger alert with a danger icon.
                &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Dismissing Alerts

    Any alert can be dismissed inline by using the alert JavaScript plugin. Refer the following points:

    • Make sure the built-in Bootstrap JavaScript or the alert plugin is loaded.
    • Add a close button and the .alert-dismissible class, which places the close button and provides extra padding to the right of the alert.
    • The JavaScript feature can be turned on by adding the data-bs-dismiss="alert" attribute to the close button.

    Let us see this feature in the following example:

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Alerts</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-3"><h4 class="fs-2">Dismissal of alerts</h4><div class="alert alert-primary alert-dismissible" role="alert"><strong>Primary Alert Box!</strong> Click on close icon to dismiss the alert box.
    
                &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;div class="alert alert-success alert-dismissible" role="alert"&gt;&lt;strong&gt;Success Alert Box!&lt;/strong&gt; Click on close icon to dismiss the alert box.
                &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;div class="alert alert-warning alert-dismissible" role="alert"&gt;&lt;strong&gt;Warning Alert Box!&lt;/strong&gt; Click on close icon to dismiss the alert box.
                &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Make sure to add tabindex="-1" to the element, when you are setting the focus on a non-interactive element that usually does not receive the focus, after closing an alert message. As, not doing so, might lose the focus and reset it to the start of the page, after an alert message is closed.

    Animated Alerts

    The utility classes .fade and .show create the animation effect, when you close an alert message. Let us see this feature in the following example.

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Alerts</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container mt-3"><h4 class="fs-2">Alert messages with animation</h4><div class="alert alert-info alert-dismissible fade show" role="alert"><strong>Primary Alert Box!</strong> This will close the alert box with fading effect.
    
                &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;div class="alert alert-success alert-dismissible fade show" role="alert"&gt;&lt;strong&gt;Success Alert Box!&lt;/strong&gt; This will close the alert box with fading effect.
                &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;div class="alert alert-warning alert-dismissible fade show" role="alert"&gt;&lt;strong&gt;Warning Alert Box!&lt;/strong&gt; This will close the alert box with fading effect.
                &lt;button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

  • Accordion

    This chapter will discuss about Bootstrap accordion. The accordion collapses elements vertically, shows and hides through class changes. Use the collapse JavaScript plugin to create accordions that collapse vertically.

    How it works

    In order to collapse, the accordion uses collapse internally. Use .open class to .accordion element to render an expanded accordion.

    Basic Example

    To expand and collapsethe content, click on the accordions below.https://www.tutorialspoint.com/bootstrap/examples/basic_example.php

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Accordion</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><style></style></head><body><div class="accordion" id="basicAccordion"><div class="accordion-item"><h2 class="accordion-header"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#firstCollapse" aria-expanded="true" aria-controls="firstCollapse">
    
             Bootstrap - Accordian
            &lt;/button&gt;&lt;/h2&gt;&lt;div id="firstCollapse" class="accordion-collapse collapse show" data-bs-parent="#basicAccordion"&gt;&lt;div class="accordion-body"&gt;
              The &lt;b&gt;accordion&lt;/b&gt; collapses elements vertically, shown and hidden by class change.
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="accordion-item"&gt;&lt;h2 class="accordion-header"&gt;&lt;button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#secondCollapse" aria-expanded="false" aria-controls="secondCollapse"&gt;
              Bootstrap - Buttons
            &lt;/button&gt;&lt;/h2&gt;&lt;div id="secondCollapse" class="accordion-collapse collapse" data-bs-parent="#basicAccordion"&gt;&lt;div class="accordion-body"&gt;
              You can use Bootstraps custom button styles for actions in forms, dialogs and many more.        
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Flush

    To render edge-to-edge accordions, use .accordion-flush to remove borders and rounded corners.

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Accordion</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><style></style></head><body><div class="accordion accordion-flush" id="flushAccordion"><div class="accordion-item"><h2 class="accordion-header"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
    
              data-bs-target="#flushCollapseOne" aria-expanded="false" aria-controls="flushCollapseOne"&gt;
              Bootstrap - Accordian
            &lt;/button&gt;&lt;/h2&gt;&lt;div id="flushCollapseOne" class="accordion-collapse collapse" data-bs-parent="#flushAccordion"&gt;&lt;div class="accordion-body"&gt;
              The &lt;b&gt;accordion&lt;/b&gt; collapses elements vertically, shown and hidden by class change.
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="accordion-item"&gt;&lt;h2 class="accordion-header"&gt;&lt;button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
              data-bs-target="#flushCollapseTwo" aria-expanded="false" aria-controls="flushCollapseTwo"&gt;
              Bootstrap - Buttons
            &lt;/button&gt;&lt;/h2&gt;&lt;div id="flushCollapseTwo" class="accordion-collapse collapse" data-bs-parent="#flushAccordion"&gt;&lt;div class="accordion-body"&gt;
              You can use Bootstraps custom button styles for actions in forms, dialogs and many more.
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Always open

    To keep accordion items open while another item is opened, remove data-bs-parent attribute from each .accordion-collapse.

    You can edit and try running this code using Edit & Run option.

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Accordion</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><style></style></head><body><div class="accordion" id="alwaysOpenAccordion"><div class="accordion-item"><h2 class="accordion-header"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#firstCollpaseofAlwaysOpen" aria-expanded="true" aria-controls="firstCollpaseofAlwaysOpen">
    
              Bootstrap - Accordian
            &lt;/button&gt;&lt;/h2&gt;&lt;div id="firstCollpaseofAlwaysOpen" class="accordion-collapse collapse show"&gt;&lt;div class="accordion-body"&gt;
              The &lt;b&gt;accordion&lt;/b&gt; collapses elements vertically, shown and hidden by class change.
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="accordion-item"&gt;&lt;h2 class="accordion-header"&gt;&lt;button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#secondCollpaseofAlwaysOpen" aria-expanded="false" aria-controls="secondCollpaseofAlwaysOpen"&gt;
              Bootstrap - Buttons
            &lt;/button&gt;&lt;/h2&gt;&lt;div id="secondCollpaseofAlwaysOpen" class="accordion-collapse collapse"&gt;&lt;div class="accordion-body"&gt;
              The &lt;b&gt;accordion&lt;/b&gt; collapses elements vertically, shown and hidden by class change.
            &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Accessibility

    See collapse accessibility section for details.

  • Figures

    This chapter discusses about the figure component of Bootstrap. Consider utilizing the <figure> element whenever you have a need to exhibit content, such as an image that may be accompanied by an optional caption.

    • <figure> element is used to markup a photo or an image in a document and <figcaption> is used to define a caption to that photo.
    • The .figure class is used to create a responsive container for images, videos, or other media objects.
    • It provides a way to wrap media content along with optional captions and other related elements.
    • The classes .figure, .figure-img and .figure-caption provide baseline styles for the <figure> and <figcaption>.
    • Use .img-fluid class to your <img>, in order to make it responsive; as the images in figures have no explicit size.

    Let us see an example of .figure class

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Figures</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container"><h4>Figures</h4><br><figure class="figure"><img src="/bootstrap/images/scenery.jpg" class="figure-img img-fluid rounded" alt="Image in Figure"><figcaption class="figure-caption">A caption for the responsive image.</figcaption></figure></body></html>

    The alignment of the caption can be changed using the text utilities, such as .text-start, .text-center or .text-end.

    Let us see an example for changing the alignment of caption

    Example

    You can edit and try running this code using the Edit & Run option.

    <!DOCTYPE html><html><head><title>Bootstrap - Figures</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><div class="container"><h4>Figure caption alignment</h4><br><figure class="figure"><img src="/bootstrap/images/tutimg.png" class="figure-img img-fluid rounded" alt="Image in Figure"><figcaption class="figure-caption text-center">Responsive image</figcaption></figure></body></html>

    Print Page