Bootstrap – Headers Demo

Bootstrap – Headers Demo ”; Previous Next What is a header? A header refers to the top section of a website, containing elements like the site”s logo, navigation menu, and other relevant information. The header is an essential part of a website”s layout. The <header> tag is an HTML element that defines a header section for the webpage. It is commonly placed at the top of the page. Some of the examples of the headers are as follows. Example Description Download link Simple header This example shows a simple header section with a logo and a title along with a navigation menu. Download Header at center This example shows a header section at center position. Download Header with buttons This example shows a header containing login and logout buttons on the right. Download Dark header This example shows dark header structure. Download Header with dropdown menu This example shows a header with a user dropdown menu on the right. Download Header with textbox This example shows header with dropdown menu and textbox. Download Double header This example shows a double header that includes a website logo, text, and search input field. Download Double header with icons This example shows a double header layout with icons. Download Print Page Previous Next Advertisements ”;

Bootstrap – Stacks

Bootstrap – Stacks ”; Previous Next This chapter discusses about stacks. A stack is an utility class that can be used to control the stacking of content within a container. The stack utility class controls the stacking order of elements. Stacks offer a quick and easy way of applying the flexbox properties to create layouts in Bootstrap. Vertical stack The class .vstack is used to create vertical layouts. The utilities such as .gap-* can be used to add space between items. By default, the stacked items are full-width. The example given below shows the usage of .vstack class: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Helper – Stack</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> <h4>Vertical stack example</h4><br> <div class=”vstack gap-1″> <div class=”text-bg-secondary p-2″>Item on First place</div> <div class=”text-bg-primary p-2″>Item on Second place</div> <div class=”text-bg-info p-2″>Item on Third place</div> </div> </body> </html> Stack the buttons or any other elements, using the class .vstack. Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Helper – Stack</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> <h4>Vertical stack using buttons</h4><br> <div class=”vstack gap-3 col-md-4 mx-auto”> <button type=”button” class=”btn btn-success”>Confirm changes</button> <button type=”button” class=”btn btn-secondary”>Cancel</button> </div> </body> </html> Horizontal stack The class .hstack is used to create horizontal layouts. The utilities such as .gap-* can be used to add space between items. By default, the stacked items are vertically centered and only take up their necessary width. The example given below shows the usage of .hstack class: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Helper – Stack</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> <h4>Horizontal stack example</h4><br> <div class=”hstack gap-3 column-gap-3″> <div class=”text-bg-warning p-2″>Item one</div> <div class=”text-bg-light p-2″>Item two</div> <div class=”text-bg-secondary p-2″>Item three</div> </div> </body> </html> The horizontal margin utility like .ms-auto can be used to add spaces. The utility class .ms-auto aligns the text to the right of the screen. Let”s see an example: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Helper – Stack</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> <h4>Horizontal margin example</h4><br> <div class=”hstack gap-3 column-gap-3″> <div class=”text-bg-primary p-2″>Item one</div> <div class=”text-bg-secondary p-2″>Item two</div> <div class=”text-bg-info p-2 ms-auto”>Item three</div> </div> </body> </html> Vertical rules such as the class .vr is used to create a vertical divider. Let”s see an example for the same. The example given below shows the usage of .vr class: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Helper – Stack</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> <h4>Horizontal stack with vertical rule</h4><br> <div class=”hstack gap-3 column-gap-3″> <div class=”text-bg-secondary p-3″>Item one</div> <div class=”vr”></div> <div class=”text-bg-warning p-3″>Item two</div> <div class=”vr”></div> <div class=”text-bg-info p-3″>Item three</div> </div> </body> </html> An inline form can be created using the class .hstack. Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Helper – Stack</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> <h4>Create an inline form</h4><br> <div class=”hstack gap-2″> <input class=”form-control me-auto” type=”text” placeholder=”Add text here…” aria-label=”Add text here…”> <div class=”vr”></div> <button type=”button” class=”btn btn-success”>Submit</button> <div class=”vr”></div> <button type=”button” class=”btn btn-outline-danger”>Clear</button> </div> </body> </html> Print Page Previous Next Advertisements ”;

Bootstrap – Popovers

Bootstrap – Popovers ”; Previous Next This chapter will discuss about popovers in Bootstrap. A popover typically contains additional information, context, or actions related to the triggering element. The popover may contain text, images, links, buttons, or other content, depending on its purpose and context. Bootstrap provides built-in popover components that can be easily integrated into web applications. Things to remember while using the popover plug-in: As popovers depend on Popper.js, a third party library, for positioning, you must include popper.min.js before bootstrap.js. As a dependency, the popovers require the popover plugin. You must initialize the popovers first, as popovers are opt-in for performance reasons. A popover will never be shown for a zero-length title and content values. Triggering popovers will not work on hidden elements. Popovers for .disabled or disabled elements must be triggered using a wrapper element. To avoid getting popovers centered between the anchors” overall width, use white-space: nowrap; on the <a> Before removing any element from the DOM, you must hide the popovers corresponding to them. Enable Popovers Initialize all the popovers on a page, by their data-bs-toggle attribute const popoverTriggerList = document.querySelectorAll(”[data-bs-toggle=”popover”]”) const popoverList = […popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)) Creating a Popover Add the data-bs-toggle=”popover” attribute to an element, to create a popover. The data-bs-toggle attribute defines the popover. The title attribute defines the title of the popover The data-content attribute defines the content to be shown in the respective popover. Example Let”s see an example of creating a popover: You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Popover</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”> <link href=”https://getbootstrap.com/docs/5.3/assets/css/docs.css” rel=”stylesheet”> <script src=”https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js”></script> </head> <body> <h4>Bootstrap creation</h4><br><br> <button type=”button” class=”btn btn-primary” data-bs-toggle=”popover” data-bs-placement=”top” data-bs-title=”Popover” data-bs-content=”It is a new popover.”> Click to view popover </button> <script> const popoverTriggerList = document.querySelectorAll(”[data-bs-toggle=”popover”]”) const popoverList = […popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)) </script> </body> </html> Positioning of a Popover There are four options available for the positioning of the popover: left, right, top and bottom aligned. By default, the popover will appear on the right of the element. The data-bs-placement attribute is used to set the position of the popover. Example Let”s see an example of setting the position of a popover: You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Popovers</title> <meta charset=”UTF-8″> <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”> <link href=”https://getbootstrap.com/docs/5.3/assets/css/docs.css” rel=”stylesheet”> <script src=”https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js”></script> </head> <body> <h4>Positioning of Popover</h4> <br><br><br> <button type=”button” class=”btn btn-secondary” data-bs-container=”body” data-bs-toggle=”popover” data-bs-placement=”top” data-bs-content=”Top popover”> Popover on top </button> <button type=”button” class=”btn btn-secondary” data-bs-container=”body” data-bs-toggle=”popover” data-bs-placement=”right” data-bs-content=”Right popover”> Popover on right </button> <button type=”button” class=”btn btn-secondary” data-bs-container=”body” data-bs-toggle=”popover” data-bs-placement=”bottom” data-bs-content=”Bottom popover”> Popover on bottom </button> <button type=”button” class=”btn btn-secondary” data-bs-container=”body” data-bs-toggle=”popover” data-bs-placement=”left” data-bs-content=”Left popover”> Popover on left </button> <script> const popoverTriggerList = document.querySelectorAll(”[data-bs-toggle=”popover”]”) const popoverList = […popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)) </script> </body> </html> Custom popovers The appearance of popovers can be customized using a custom class data-bs-custom-class=”custom-popover”. Example Let”s see an example of creating a custom popover: You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head&> <title>Bootstrap – Popovers</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> <h4>Custom Popover</h4><br><br> <!– Define custom container –> <button type=”button” class=”btn btn-primary” data-bs-toggle=”popover” data-bs-placement=”top” data-bs-custom-class=”custom-popover” data-bs-title=”Custom popover” data-bs-content=”It is a custom popover.”> Custom popover </button> <script> const popoverTriggerList = document.querySelectorAll(”[data-bs-toggle=”popover”]”) const popoverList = […popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)) </script> </body> </html> Dismissible Popover The popover gets closed when the same element is clicked again, by default. However, the attribute data-bs-trigger=”focus” can be used, which will close the popover when clicking outside the element. For the popover to be dismissed on the next click, it is necessary to use specific HTML code that ensures consistent behavior across different browsers and platforms Example Let”s see an example of dismissible popover: You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Dismissible Popover</title> <meta charset=”UTF-8″> <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>Dismissed on next click – Popover</h4><br> <a href=”#” title=”Dismissible popover” data-bs-toggle=”popover” data-bs-trigger=”focus” data-bs-content=”Click anywhere in the document to close this popover”>Click me</a> </div> <script> const popoverTriggerList = document.querySelectorAll(”[data-bs-toggle=”popover”]”) const popoverList = […popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)) </script> </body> </html> Hovering of a Popover When the mouse pointer is moved over an element and you want a popover to appear on hovering, use the data-bs-trigger=”hover” attribute. Example Let”s see an example of a hovering popover: You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Popover on hover</title> <meta charset=”UTF-8″> <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>Hoverable Popover</h4><br> <a href=”#” title=”Header” data-bs-toggle=”popover” data-bs-trigger=”hover” data-bs-content=”Popover text”>Hover over me</a> </div> <script> const popoverTriggerList = document.querySelectorAll(”[data-bs-toggle=”popover”]”) const popoverList = […popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)) </script> </body> </html> Popover on disabled elements For popovers on disabled elements, you may prefer data-bs-trigger=”hover focus” so that the popover appears as immediate visual feedback to your users as they may not expect to click on a disabled element. Example Let”s see an example of a popover on disabled element: You can edit and try running this code using the Edit & Run option.

Bootstrap – Icon Link

Bootstrap – Icon link ”; Previous Next This chapter discusses about icon links, through which you can stylize the hyperlinks and other icons. In Bootstrap, an icon link is a link that is accompanied by an icon. The icon can be positioned either before or after the link text, and it is typically used to provide additional context or visual cues to the user. Icon links can be useful for adding visual interest and interactivity to your website or application, and they can be used in a variety of contexts such as navigation menus, buttons, or calls to action. The default link styles are modified by the icon link helper classes. They automatically align any pairing of icon and text and thus enhance their appearance on the page. Bootstrap icons along with any icon or image can be used in the icon links. Icons that are added only with the purpose of decoration, should be hidden from assistive technologies using aria-hidden=”true”. Icons that are added with purpose of conveying some meaning or information, provide an appropriate text alternative by adding role=”img” along with appropriate aria-label. Example To a regular <a> element, add .icon-link Insert an icon on either side of the link text. The .icon-link class will automatically size, place and color the icon. You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Icon Link</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> <link rel=”apple-touch-icon” href=”/docs/5.3/assets/img/favicons/apple-touch-icon.png” sizes=”180×180″> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon-32×32.png” sizes=”32×32″ type=”image/png”> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon-16×16.png” sizes=”16×16″ type=”image/png”> <link rel=”manifest” href=”/docs/5.3/assets/img/favicons/manifest.json”> <link rel=”mask-icon” href=”/docs/5.3/assets/img/favicons/safari-pinned-tab.svg” color=”#712cf9″> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon.ico”> <link rel=”canonical” href=”https://icons.getbootstrap.com/icons/search/”><script src=”/assets/js/color-modes.js”></script> <link rel=”stylesheet” href=”/assets/font/bootstrap-icons.min.css”><link rel=”stylesheet” href=”/assets/css/docs.css”> </head> <body> <nav class=”navbar navbar-inverse navbar-fixed-top text-bg-light” role=”navigation”> <div class=”container”> <div class=”navbar-header”> <h1 class=”logo”> <a title=”tutorialspoint”> <img alt=”tutorialspoint” src=”http://www.tutorialspoint.com/green/images/logo.png” style=”height: auto; width: auto; display: inline-block; top: 0px;”> </a> </h1> </div> </div> </nav> <div class=”container mt-2″> <svg xmlns=”http://www.w3.org/2000/svg” style=”display: none;”> <symbol id=”box-seam” viewBox=”0 0 16 16″> <path d=”M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5l2.404.961L10.404 2l-2.218-.887zm3.564 1.426L5.596 5 8 5.961 14.154 3.5l-2.404-.961zm3.25 1.7-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.838L1 4.239v7.923l6.5 2.6zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464L7.443.184z”></path> </symbol> </svg> <div class=”feature col”> <h3 class=”fs-2 text-danger”>Icon link example</h3> <p>Icon link feature of Bootstrap allows a user to add an icon along with an hyperlink and even the icon works as a link.</p> <a class=”icon-link” href=”#”> <svg class=”bi” aria-hidden=”true”> <use xlink:href=”#box-seam”></use></svg> Box Icon with text link </a> </div> </body> </html> Let us see another example where icon is placed after the text in an icon link: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Icon Link</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> <link rel=”apple-touch-icon” href=”/docs/5.3/assets/img/favicons/apple-touch-icon.png” sizes=”180×180″> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon-32×32.png” sizes=”32×32″ type=”image/png”> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon-16×16.png” sizes=”16×16″ type=”image/png”> <link rel=”manifest” href=”/docs/5.3/assets/img/favicons/manifest.json”> <link rel=”mask-icon” href=”/docs/5.3/assets/img/favicons/safari-pinned-tab.svg” color=”#712cf9″> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon.ico”> <link rel=”canonical” href=”https://icons.getbootstrap.com/icons/search/”><script src=”/assets/js/color-modes.js”></script> <link rel=”stylesheet” href=”/assets/font/bootstrap-icons.min.css”><link rel=”stylesheet” href=”/assets/css/docs.css”> </head> <body> <nav class=”navbar navbar-inverse navbar-fixed-top text-bg-light” role=”navigation”> <div class=”container”> <div class=”navbar-header”> <h1 class=”logo”> <a title=”tutorialspoint”> <img alt=”tutorialspoint” src=”http://www.tutorialspoint.com/green/images/logo.png” style=”height: auto; width: auto; display: inline-block; top: 0px;”> </a> </h1> </div> </div> </nav> <div class=”container mt-2″> <svg xmlns=”http://www.w3.org/2000/svg” style=”display: none;”> <symbol id=”airplane-fill” viewBox=”0 0 16 16″> <path d=”M6.428 1.151C6.708.591 7.213 0 8 0s1.292.592 1.572 1.151C9.861 1.73 10 2.431 10 3v3.691l5.17 2.585a1.5 1.5 0 0 1 .83 1.342V12a.5.5 0 0 1-.582.493l-5.507-.918-.375 2.253 1.318 1.318A.5.5 0 0 1 10.5 16h-5a.5.5 0 0 1-.354-.854l1.319-1.318-.376-2.253-5.507.918A.5.5 0 0 1 0 12v-1.382a1.5 1.5 0 0 1 .83-1.342L6 6.691V3c0-.568.14-1.271.428-1.849Z”></path> </symbol> </svg> <div class=”feature col”> <h3 class=”fs-2 text-success”>Icon link example</h3> <p>Icon link feature of Bootstrap allows a user to add an icon along with an hyperlink and even the icon works as a link. Here the icon is placed after the text in the icon link.</p> <a class=”icon-link” href=”#”>Icon after the text <svg class=”bi” aria-hidden=”true”> <use xlink:href=”#airplane-fill”></use> </svg> </a> </div> </body> </html> Style on hover In order to move the icon in an icon link to right, add the utility class .icon-link-hover to the class .icon-link. Let us see an example: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Icon Link</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> <link rel=”apple-touch-icon” href=”/docs/5.3/assets/img/favicons/apple-touch-icon.png” sizes=”180×180″> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon-32×32.png” sizes=”32×32″ type=”image/png”> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon-16×16.png” sizes=”16×16″ type=”image/png”> <link rel=”manifest” href=”/docs/5.3/assets/img/favicons/manifest.json”> <link rel=”mask-icon” href=”/docs/5.3/assets/img/favicons/safari-pinned-tab.svg” color=”#712cf9″> <link rel=”icon” href=”/docs/5.3/assets/img/favicons/favicon.ico”> <link rel=”canonical” href=”https://icons.getbootstrap.com/icons/search/”><script src=”/assets/js/color-modes.js”></script> <link rel=”stylesheet” href=”/assets/font/bootstrap-icons.min.css”><link rel=”stylesheet” href=”/assets/css/docs.css”> </head> <body> <nav class=”navbar navbar-inverse navbar-fixed-top text-bg-light” role=”navigation”> <div class=”container”> <div class=”navbar-header”> <h1 class=”logo”> <a title=”tutorialspoint”> <img alt=”tutorialspoint” src=”http://www.tutorialspoint.com/green/images/logo.png” style=”height: auto; width: auto; display: inline-block; top: 0px;”> </a> </h1> </div> </div> </nav> <div class=”container mt-2″> <svg xmlns=”http://www.w3.org/2000/svg” style=”display: none;”> <symbol id=”chevron-right” viewBox=”0 0 16 16″> <path d=”M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z”></path> </symbol> </svg> </div> <div class=”feature col”> <h3 class=”fs-2 text-success”>Icon link example – hover</h3> <p>Icon link feature of Bootstrap allows a user to add an icon along with an hyperlink and even the icon works as a link. Here the icon moves to the right on hovering.</p> <a class=”icon-link icon-link-hover” href=”#”><strong>Icon link hover</strong> <svg class=”bi” aria-hidden=”true”> <use xlink:href=”#chevron-right”></use> </svg> </a> </div> </body> </html> Utilities In order to modify the underline color and offset of the icon link, use the custom link utilities provided by Bootstrap. To add color to the iconlink, use the class link-* (where * can be any color-modes like danger, success, warning, info, etc.)

Bootstrap – Spinners

Bootstrap – Spinners ”; Previous Next This chapter will discuss about Bootstrap spinners. Bootstrap spinner display the loading state of projects using .spinner class. How it works Bootstrap spinners show the loading state of a project, using HTML and CSS. JavaScript is not required to build them. Custom JavaScript is needed to toggle their visibility. Appearance, alignment, and sizing can be easily customized with Bootstrap”s utility classes. Each loader has role=”status” and a nested <span class=”visually-hidden”>Loading… </span > for accessibility. Border spinner Use .spinner-border class to create lightweight spinner/loading indicator. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h3>Border Spinner</h3> <div class=”spinner-border mt-2″ role=”status”> <span class=”spinner-grow text-white spinner-grow-sm” role=”status”></span> <span class=”visually-hidden”></span> </div> </body> </html> Colors Border spinner uses currentColor for its border-color, which is customizable with text color utilities. Use text color utilities on a standard spinner. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h3>Colored Spinner</h3> <div class=”spinner-border text-primary” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-border text-secondary” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-border text-success” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-border text-danger” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-border text-warning” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-border text-info” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-border text-light” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-border text-dark” role=”status”> <span class=”visually-hidden”></span> </div> </body> </html> Why not use border-color utilities? Border spinners have transparent border on one side, overridden by .border-{color} utilities. Growing spinner You can change the spin type of spinner to the grow spinner. It technically doesn”t rotate, but it repeatedly grows. Use .spinner-grow class to create grow spinner. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h3>Growing Spinner</h3> <div class=”spinner-grow” role=”status”> <span class=”visually-hidden”></span> </div> </body> </html> This spinner uses currentColor to change its appearance with text color utilities. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h3>Growing color Spinners</h3> <div class=”spinner-grow text-primary” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow text-secondary” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow text-info” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow text-dark” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow text-warning” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow text-success” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow text-light” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow text-danger” role=”status”> <span class=”visually-hidden”></span> </div> <div class=”spinner-grow” role=”status”> <span class=”visually-hidden”></span> </div> </body> </html> Alignment Bootstrap spinners are designed with rems, currentColor, and display: inline-flex. They are easily resizable, recolorable, and alignable. Margin For simple spacing, use margin utilities like .m-4. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h3>Margin</h3> <div class=”spinner-border m-4″ role=”status”> <span class=”visually-hidden”></span> </div> </body> </html> Placement Bootstrap spinners can be placed using flexbox utilities, float utilities, or text alignment utilities. Flex Use flexbox placement classes to set the position of spinners. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h5 class=”text-center”>Flex placement at start, center, end</h5> <div class=”d-flex justify-content-start”> <div class=”spinner-border” role=”status”> <span class=”visually-hidden”></span> </div> </div> <div class=”d-flex justify-content-center”> <div class=”spinner-border” role=”status”> <span class=”visually-hidden”></span> </div> </div> <div class=”d-flex justify-content-end”> <div class=”spinner-border” role=”status”> <span class=”visually-hidden”></span> </div> </div> </body> </html> You can change spinner alignment using flexbox placement. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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=”d-flex align-items-end mt-2″> <h5 class=”text-center”>Flex placement</h5> <div class=”spinner-border ms-auto” role=”status” aria-hidden=”true”></div> </div> </body> </html> Float Use float placement classees to set the position of spinners. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h5>Float placement at start and end</h5> <div class=”clearfix float-start mt-2″> <div class=”spinner-border” role=”status”> <span class=”visually-hidden”></span> </div> </div> <div class=”clearfix float-end”> <div class=”spinner-border” role=”status”> <span class=”visually-hidden”></span> </div> </div> </body> </html> Text align Use .text-align placement classes to set the position of spinners items. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Spinners</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> <h5 class=”text-center”>Text Align at start, center, end</h5> <div class=”text-start”> <div class=”spinner-border” role=”status”> <span class=”visually-hidden”></span> </div> </div> <div class=”text-center”> <div class=”spinner-border” role=”status”> <span class=”visually-hidden”></span> </div> </div> <div class=”text-end”> <div class=”spinner-border” role=”status”>

Bootstrap – Floating Labels

Bootstrap – Floating Labels ”; Previous Next This chapter will discuss about Bootstrap floating labels. Floating labels refer to form labels that float over the input fields. Basic example To allow floating labels with Bootstrap”s textual form fields, include a pair of <input class=”form-control”> and <label> elements in .form-floating. Each <input> must have a placeholder since the technique for CSS-only floating labels employs the :placeholder-shown pseudo-element. The <input> needs to be placed first to make use of a sibling selector like (~). Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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=”form-floating mb-3 mt-2″> <input type=”text” class=”form-control” id=”floatingUsername” placeholder=”[email protected]”> <label for=”floatingUsername”>Username</label> </div> <div class=”form-floating”> <input type=”password” class=”form-control” id=”floatingPassword” placeholder=”Password”> <label for=”floatingPassword”>Password</label> </div> </body> </html> When a value is already assigned, <label> elements will automatically align their position to float over the input field. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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> <form class=”form-floating mt-2″> <input type=”email” class=”form-control” id=”floatingInputValue” placeholder=”[email protected]” value=”[email protected]”> <label for=”floatingInputValue”>Username</label> </form> </body> </html> By using form validation styles like is-invalid, you can provide visual feedback to users when they submit incorrect data. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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> <form class=”form-floating”> <input type=”text” class=”form-control is-invalid” id=”floatingInvalidInput” placeholder=”Password” value=”Password”> <label for=”floatingInvalidInput”>Invalid Password</label> </form> </body> </html> Textareas The height of <textarea> with the class .form-control is automatically set to have the same height as <input>. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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=”form-floating”> <textarea class=”form-control” placeholder=”Text Here” id=”floatingTextarea”></textarea> <label for=”floatingTextarea”>Text Here</label> </div> </body> </html> Don”t use the rows attribute if you want to customize the height of your <textarea>. Instead, specify a height explicitly (either inline or using customized CSS). In the below example we have used inline styling. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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=”form-floating”> <textarea class=”form-control” placeholder=”Add a comment” id=”floatingTextarea” style=”height: 100px”></textarea> <label for=”floatingTextarea”>Add a comment</label> </div> </body> </html> Selects Floating labels are only accessible on .form-selects, in addition to .form-control. The same concepts apply to them, except unlike <input>s, they always display the <label> in its floated state. Size-based and multiple selects are not supported. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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=”form-floating”> <select class=”form-select” id=”floatingSelect” aria-label=”Floating label select menu”> <option selected>Language</option> <option value=”1″>English</option> <option value=”2″>Hindi</option> <option value=”3″>Marathi</option> </select> <label for=”floatingSelect”>Others</label> </div> </body> </html> Disabled Add the disabled boolean attribute on an input. This gives grayed-out appearance to an input, textarea, or select. It also removes pointer events, and prevents focusing. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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=”form-floating mb-3″> <input type=”email” class=”form-control” id=”floatingInputDisabled” placeholder=”name” disabled> <label for=”floatingInputDisabled”>Name</label> </div> <div class=”form-floating mb-3″> <textarea class=”form-control” placeholder=”[email protected]” id=”floatingEmailDisabled” disabled></textarea> <label for=”floatingEmailDisabled”>Email Id</label> </div> <div class=”form-floating mb-3″> <textarea class=”form-control” placeholder=”Add a comment” id=”floatingTextareaDisabled” style=”height: 120px” disabled></textarea> <label for=”floatingTextareaDisabled”>Add a comment</label> </div> <div class=”form-floating”> <select class=”form-select” id=”floatingSelectDisabled” aria-label=”Floating label disabled select example” disabled> <option selected>Select Language</option> <option value=”1″>English</option> <option value=”2″>Hindi</option> <option value=”3″>Marathi</option> </select> <label for=”floatingSelectDisabled”>Others</label> </div> </body> </html> Readonly plaintext When switching from an editable <input> to a plaintext value without changing the page layout, .form-control-plaintext can be useful. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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=”form-floating mb-3 mt-2″> <input type=”text” readonly class=”form-control” id=”floatingEmptyPlaintextInput” style=”height: 80px” placeholder=”Block the comment” value=”Block the comment”> <label for=”floatingEmptyPlaintextInput”>Block the comment</label> </div> <div class=”form-floating mb-3″> <input type=”text” readonly class=”form-control” id=”floatingPlaintextInput” style=”height: 80px” placeholder=”Add a comment” value=”Add a comment”> <label for=”floatingPlaintextInput”>Add a comment</label> </div> </body> </html> Input groups Similarly, floating labels support .input-group. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Floating Labels</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=”input-group mb-3″> <div class=”form-floating”> <input type=”email” class=”form-control” id=”floatingInputGroup” placeholder=”email”> <label for=”floatingInputGroup”>Email Id</label> </div> <span class=”input-group-text”>[email protected]</span> </div> </body> </html> The -feedback (it is a validation class to provide valuable feedback to users before submitting the form.) should

Bootstrap – Vertical Align

Bootstrap – Vertical align ”; Previous Next This chapter discusses about the vertical alignment utilities provided by Bootstrap. You can change the vertical alignment of inline, inline-block, inline-table, and table cell elements. Choose from following classes as per your need: .align-baseline .align-top .align-middle .align-bottom .align-text-bottom .align-text-top In order to align the non-inline content, use flex box utilities Let us see an example to align the inline elements: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html> <head> <title>Bootstrap – Vertical align</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=”display-5″>Vertical align</h4> <p>Change the alignment of elements with the align classes (only works on inline, inline-block, inline-table and table cell elements):</p><br><br> <button class=”btn align-baseline text-bg-success”>align baseline</button> <button class=”btn align-top text-bg-success”>align top</button> <button class=”btn align-middle text-bg-success”>align middle</button> <button class=”btn align-bottom text-bg-success”>align bottom</button> <button class=”btn align-text-top text-bg-success”>align text top</button> <button class=”btn align-text-bottom text-bg-success”>align text bottom </button> </div> </body> </html> Let us see an example to align the table cell elements: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html> <head> <title>Bootstrap – Vertical align</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=”display-5″>Vertical Align – Table cell elements</h4> <p>Change the alignment of elements with the align classes (only works on inline, inline-block, inline-table and table cell elements):</p><br><br> <table class=”table-bordered bg-light” style=”height: 100px;”> <tbody> <tr> <td class=”p-2 align-baseline”>align baseline</td> <td class=”p-2 align-top”>align top</td> <td class=”p-2 align-middle”>align middle</td> <td class=”p-2 align-bottom”>align bottom</td> <td class=”p-2 align-text-top”>align-text-top</td> <td class=”p-2 align-text-bottom”>align-text-bottom</td> </tr> </tbody> </table> </div> </body> </html> Print Page Previous Next Advertisements ”;

Bootstrap – Buttons

Bootstrap – Buttons ”; Previous Next This chapter will discuss about Bootstrap Buttons.You can use Bootstrap’s custom button styles for actions in forms, dialogs and many more. This support for multiple sizes, states,…etc. Bootstrap includes the class .btn that sets basic styles such as padding and content alignment. Base button Add .btn class that implements basic styles such as padding and content alignment. The .btn class provides a transparent border, a background color, and no explicit focus and hover styles. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html> <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 – Buttons</title> </head> <body> <button type=”button” class=”btn btn-primary”>Base Button </button> </body> </html> Variants Bootstrap includes different styles of buttons, each serving its own semantic purpose, with some extras thrown in for further control. To achieve the button styles, Bootstrap provides following classes: .btn .btn-default .btn-primary .btn-success .btn-info .btn-warning .btn-danger .btn-link 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 – Buttons</title> </head> <body> <button type=”button” class=”btn btn-primary”>Primary</button> <button type=”button” class=”btn btn-secondary”>Secondary</button> <button type=”button” class=”btn btn-success”>Success</button> <button type=”button” class=”btn btn-danger”>Danger</button> <button type=”button” class=”btn btn-warning”>Warning</button> <button type=”button” class=”btn btn-info”>Info</button> <button type=”button” class=”btn btn-light”>Light</button> <button type=”button” class=”btn btn-dark”>Dark</button> <button type=”button” class=”btn btn-link”>Link</button> </body> </html> Disabled text wrapping To disable the text wrapping on a button text, add .text-nowrap class to the button. 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 – Buttons</title> </head> <body> <button type=”button” class=”btn btn-primary text-nowrap”>this button”s text has disabled text wrapping. Here we see the test in a single line</button><br><br><br> <button type=”button” class=”btn btn-primary”>this button”s text does not have text wrapping enabled. Here we see the text being wrapped to next line</button> </body> </html> Button tags The .btn classes can be used on <a> and <input> elements. When you are using button classes on <a> elements that used to trigger in-page functionality instead of linking to new pages or sections within the current page these links have element role=”button” to appropriately convey their purpose to assistive technologies such as screen readers. 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 – Buttons</title> </head> <body> <a href=”#”role=”button” class=”btn btn-info”>Download Link</a> <button type=”button” class=”btn btn-primary”>Button</button> <input type=”submit” class=”btn btn-secondary” value=”Submit”> <input type=”button” class=”btn btn-danger” value=”Login”> <input type=”reset” class=”btn btn-light” value=”Reset”> </body> </html> Outline button To get the button without heavy background colors, use .btn-outline-* class which allows you to remove all background images and colors from any button. 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 – Buttons</title> </head> <body> <button type=”button” class=”btn btn-outline-primary”>Primary Button</button> <button type=”submit” class=”btn btn-outline-secondary”>Secondary Button</button> <button type=”button” class=”btn btn-outline-warning”>Warning Button</button> <button type=”button” class=”btn btn-outline-success”>Sucess Button</button> <button type=”button” class=”btn btn-outline-light”>Light Button</button> <button type=”button” class=”btn btn-outline-danger”>Danger Button</button> <button type=”button” class=”btn btn-outline-dark”>Dark Button</button> <button type=”button” class=”btn btn-outline-info”>Info Button</button> <button type=”button” class=”btn btn-outline-link”>Link</button> </button> </body> </html> Button sizes To get any larger or smaller buttons add the classes .btn-lg, .btn-sm to the .btn. You can create your own custom size button by using CSS variables. 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 – Buttons</title> </head> <body> <button type=”button” class=”btn btn-primary btn-lg”>Large button</button> <button type=”button” class=”btn btn-info btn-sm”>Small Button</button> <button type=”button” class=”btn btn-warning” style=”–bs-btn-padding-y: .24rem; –bs-btn-padding-x: .8rem; –bs-btn-font-size: .75rem;”> Custom Button </button> </body> </html> Disabled state Bootstrap provides class .disabled. This feature disables from hovering and active states of click event. 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 – Buttons</title> </head> <body> <button type=”button” class=”btn btn-primary disabled”>Primary Disabled Button</button> <button type=”button” class=”btn btn-secondary” disabled>Secondary Disabled Button</button> <button type=”button” class=”btn btn-outline-primary” disabled>Outline Primary Disabled button</button> <button type=”button” class=”btn btn-outline-secondary” disabled>Outline Secondary Disabled Button</button> </button> </body> </html> Disabled buttons using the <a> element that has slightly different behavior: The element <a> doesn”t support the disabled attribute. You have to add the .disabled class to make it visually seem disabled. To disable all pointer-events on anchor buttons, some future-friendly styles are included. To show the state of the element to assistive technologies in disabled buttons using <a> should contain aria-disabled=”true” attribute. The href attribute should not be included within disabled buttons using <a>. 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 – Buttons</title> </head> <body> <a class=”btn btn-primary disabled” role=”button” aria-disabled=”true”>Primary Disabled</a>

Bootstrap – Checks & radios

Bootstrap – Checkbox and Radios ”; Previous Next This chapter will discuss about checkbox and radios utilities provided by Bootstrap. Checkboxes allow you to select one or more alternatives from a list, whereas radio buttons allow you to choose only one. Approach Bootstrap provides wrapper class .form-check for improved layout and behavior of browser default checkboxes and radios elements. It also allows greater customization and cross browser consistency. .form-check-label class is used to show checkbox labels. .form-check-input class is used for input type checkbox. Structurally, the input and label act as siblings. Bootstrap”s custom icons are used to display checked or indeterminate states. Checkbox Checkboxes select one or several options from a list. You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Checkbox</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=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”defaultCheck”> <label class=”form-check-label” for=”defaultCheck”> item 1 </label> </div> <div class=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”flexCheckChecked” checked> <label class=”form-check-label” for=”flexCheckChecked”> item 2 </label> </div> </body> </html> Indeterminate The :indeterminate pseudo class is used to create intermediate state checkboxes. The indeterminate state is set via JavaScript as there is no equivalent HTML attribute available to specify it. You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Checkbox</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=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”indeterminateCheckbox” > <label class=”form-check-label” for=”indeterminateCheckbox”> item 1 </label> </div> <script> var x = document.getElementById(“indeterminateCheckbox”).indeterminate = true;; </script> </body> </html> Disabled checkbox To indicate disabled state use disabled attribute. This makes the associated <label> lighter color indicating disabled state. You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Checkbox</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=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”disabledIndeterminateCheckbox” disabled> <label class=”form-check-label” for=”disabledIndeterminateCheckbox”> item 1 </label> </div> <div class=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”disabledCheckedCheckbox” checked disabled> <label class=”form-check-label” for=”disabledCheckedCheckbox”> item 2 </label> </div> <div class=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”disabledCheckbox” disabled> <label class=”form-check-label” for=”disabledCheckbox”> item 3 </label> </div> </body> <script> var x = document.getElementById(“disabledIndeterminateCheckbox”).indeterminate = true; </script> </html> Radios Radio button limits the number of choices to only one in a list. You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Radio</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=”form-check”> <input class=”form-check-input” type=”radio” name=”flexRadioDefault” id=”defaultRadio”> <label class=”form-check-label” for=”defaultRadio”> Item 1 </label> </div> <div class=”form-check”> <input class=”form-check-input” type=”radio” name=”flexRadioDefault” id=”defaultCheckRadio” checked> <label class=”form-check-label” for=”defaultCheckRadio”> Item 2 </label> </div> </body> </html> Disabled Radio Button To indicate disabled state use disabled attribute and the associated <label>”s are styled with a lighter color. You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Form – Radio</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=”form-check”> <input class=”form-check-input” type=”radio” name=”flexRadioDisabled” id=”disabledRadio” disabled> <label class=”form-check-label” for=”disabledRadio”> Item 1 </label> </div> <div class=”form-check”> <input class=”form-check-input” type=”radio” name=”flexRadioDisabled” id=”disabledCheckedRadio” checked disabled> <label class=”form-check-label” for=”disabledCheckedRadio”> Item 2 </label> </div> </body> </html> Switches The switch has the custom checkbox markup, to render the toggle use .form-switch class. Use role=”switch” to convey the type of control to assistive technologies. The switches supports the disabled attribute. The older assistive technologies just announced it as a normal checkbox as a fallback. You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Form – Radio</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=”form-check form-switch”> <input class=”form-check-input” type=”checkbox” role=”switch” id=”defaultSwitchCheckbox”> <label class=”form-check-label” for=”defaultSwitchCheckbox”>Wi-fi</label> </div> <div class=”form-check form-switch”> <input class=”form-check-input” type=”checkbox” role=”switch” id=”defaultSwitchCheckedCheckbox” checked> <label class=”form-check-label” for=”defaultSwitchCheckedCheckbox”>Bluetooth</label> </div> <div class=”form-check form-switch”> <input class=”form-check-input” type=”checkbox” role=”switch” id=”disabledSwitchCheckbox” disabled> <label class=”form-check-label” for=”disabledSwitchCheckbox”>Whatsapp Notification</label> </div> <div class=”form-check form-switch”> <input class=”form-check-input” type=”checkbox” role=”switch” id=”disabledSwitchCheckedCheckbox” checked disabled> <label class=”form-check-label” for=”disabledSwitchCheckedCheckbox”>Facebook Notification</label> </div> </body> </html> Default checkbox and radios (stacked) The radios and checkboxes can be stacked vertically using the .form-check class. You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Checkbox and Radios</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=”form-check”> <input class=”form-check-input” type=”radio” name=”Radios” id=”defaultStackedRadio” value=”option2″> <label class=”form-check-label” for=”defaultStackedRadio”> English </label> </div> <div class=”form-check”> <input class=”form-check-input” type=”radio” name=”Radios” id=”disabledStackedRadio” value=”option3″ disabled> <label class=”form-check-label” for=”disabledStackedRadio”> Hindi </label> </div> <div class=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”defaultCheckbox”> <label class=”form-check-label” for=”defaultCheckbox”> Marathi </div> <div class=”form-check”> <input class=”form-check-input” type=”checkbox” value=”” id=”disabledCheckbox” disabled> <label class=”form-check-label” for=”disabledCheckbox”> Japanes </label> </div> </body> </html> Inline To put checkboxes and radios next to each other, use the class .form-check-inline with any .form-check. Example You can edit and try running this code using Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Checkbox and Radios</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=”form-check form-check-inline”> <input class=”form-check-input” type=”radio” name=”inlineRadioOptions” id=”inlineDeafultRadio” value=”option1″> <label class=”form-check-label” for=”inlineDeafultRadio”>English</label> </div> <div class=”form-check form-check-inline”> <input class=”form-check-input” type=”radio” name=”inlineRadioOptions” id=”inlineDisabledRadio” value=”option3″ disabled>

Bootstrap – Tooltips

Bootstrap – Tooltips ”; Previous Next This chapter will discuss about adding custom Bootstrap tooltips. Tooltip is typically displayed as a small, floating box that appears when the user hovers over or clicks on a specific UI element, such as a button, icon, or hyperlink. Tooltips are used to provide context, explanations, or instructions for users who may need more information about the purpose or functionality of a UI element. Things to remember while using the tooltip plug-in: As tooltips depend on Popper, a third party library, for positioning, you must include popper.min.js before bootstrap.js or use bootstrap.bundle.min.js / bootstrap.bundle.js, which contains Popper for tooltips to work. You must initialize the tooltips first, as tooltips are opt-in for performance reasons. A tooltip will never be shown for a zero-length title value. Triggering tooltips will not work on hidden elements. Tooltips for .disabled or disabled elements must be triggered using a wrapper element. To avoid getting tooltips centered, use white-space: nowrap; on the <a> element. Before removing any element from the DOM, you must hide the tooltips corresponding to them. Inside a shadow DOM, tooltips can be triggered thanks to an element. Enable Tooltips Initialize all the tooltips on a page, by their data-bs-toggle attribute const tooltipTriggerList = document.querySelectorAll(”[data-bs-toggle=”tooltip”]”) const tooltipList = […tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) Creating a Tooltip Add the data-bs-toggle=”tooltip” attribute to an element, to create a tooltip. The data-bs-toggle attribute defines the tooltip. The title attribute defines the text to be displayed inside the tooltip. Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Tooltips</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> <h4>Bootstrap tooltip creation</h4> <button type=”button” class=”btn btn-lg btn-success” data-bs-toggle=”tooltip” title=”Tooltip description” data-content=”Tooltip desc”>View tooltip</button> <script> const tooltipTriggerList = document.querySelectorAll(”[data-bs-toggle=”tooltip”]”) const tooltipList = […tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) </script> </body> </html> Tooltips on Links Tooltips can be added to links as well using the attribute data-bs-toggle. Let”s see an example: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Tooltip</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> <h4>Tooltip on link</h4> <p class=”muted”>The <a href=”#” data-bs-toggle=”tooltip” data-bs-title=”Sample Tooltip”>tooltip</a> is used for displaying some extra information about any content. This can be added to a <a href=”#” data-bs-toggle=”tooltip” data-bs-title=”Second tooltip”>link</a>.</p> <script> const tooltipTriggerList = document.querySelectorAll(”[data-bs-toggle=”tooltip”]”) const tooltipList = […tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) </script> </body> </html> Feel free to use either title or data-bs-title in your HTML. When title is used, Popper will replace it automatically with data-bs-title when the element is rendered. Custom tooltips Bootstrap provides a custom class data-bs-custom-class=”custom tooltip” to customize the tooltip. Let”s see an example: Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Tooltip</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> <h4>Custom Tooltip</h4> <button type=”button” class=”btn btn-primary” data-bs-toggle=”tooltip” data-bs-placement=”right” data-bs-custom-class=”custom-tooltip” data-bs-title=”Tooltip is created as custom tooltip.”> Custom tooltip </button> <script> const tooltipTriggerList = document.querySelectorAll(”[data-bs-toggle=”tooltip”]”) const tooltipList = […tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) </script> </body> </html> Positioning of a Tooltip There are four options available for the positioning of the tooltip: left, right, top and bottom aligned. By default, the tooltip will appear on top of the element. The data-bs-placement attribute is used to set the position of the tooltip. Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap – Tooltip</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”> <link href=”https://getbootstrap.com/docs/5.3/assets/css/docs.css” rel=”stylesheet”> <script src=”https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js”></script> </head> <body class=”p-3 m-0 border-0 bd-example tooltip-demo”> <h4>Tooltip example – Position</h4> <button type=”button” class=”btn btn-secondary” data-bs-toggle=”tooltip” data-bs-placement=”top” data-bs-title=”Top Tooltip”> Top Tooltip </button> <button type=”button” class=”btn btn-secondary” data-bs-toggle=”tooltip” data-bs-placement=”right” data-bs-title=”Right Tooltip”> Right Tooltip </button> <button type=”button” class=”btn btn-secondary” data-bs-toggle=”tooltip” data-bs-placement=”bottom” data-bs-title=”Bottom Tooltip”> Bottom Tooltip </button> <button type=”button” class=”btn btn-secondary” data-bs-toggle=”tooltip” data-bs-placement=”left” data-bs-title=”Left Tooltip”> Left Tooltip </button> <script> const tooltipTriggerList = document.querySelectorAll(”[data-bs-toggle=”tooltip”]”) const tooltipList = […tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) </script> </body> </html> Tooltip with custom HTML The example given below shows a tooltip with custom HTML added. Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Tooltips</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> <h4>Bootstrap tooltip creation with HTML</h4> <button type=”button” class=”btn btn-secondary” data-bs-toggle=”tooltip” data-bs-html=”true” title=”<em>Tooltip</em> <u>with</u> <b>HTML</b>”> Tooltip with HTML </button> <script> const tooltipTriggerList = document.querySelectorAll(”[data-bs-toggle=”tooltip”]”) const tooltipList = […tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) </script> </body> </html> Markup For a tooltip on any HTML element, the required markup for the tooltip is only a data attribute and title. The markup of a tooltip that is generated is simple and is set to top, be default. Example You can edit and try running this code using the Edit & Run option. <!DOCTYPE html> <html lang=”en”> <head> <title>Bootstrap Tooltips</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> <h4>Bootstrap tooltip markup</h4> <!– HTML to write –> <a href=”#” data-bs-toggle=”tooltip” title=”Markup for a tooltip!”>Hover over me for markup</a> <!– Generated markup by the plugin –> <div class=”tooltip bs-tooltip-top” role=”tooltip”> <div class=”tooltip-arrow”></div> <div class=”tooltip-inner”> Markup for a tooltip </div> </div> <script> const tooltipTriggerList = document.querySelectorAll(”[data-bs-toggle=”tooltip”]”) const