Author: saqibkhan

  • Carousel demo

    What is a carousel?

    A carousel in bootstrap is a slideshow component that allows users to display multiple images, videos, or other types of content in a looping sequence. It is a responsive and dynamic component that can be easily customized.

    Bootstrap provides a set of classes that can be used to create a carousel component and customize it.

    Two main classes for adding carousel are:

    classdescription
    .carouselThis class sets up the basic structure of the carousel
    .carousel-itemThis class is used to define the individual slides within the carousel

    Optional classes to customize the slides in a carousel are:

    classdescription
    .slideAdds a sliding animation to the carousel
    .activeDefines the initial active slide
    .carousel-indicatorsAdds navigation indicators to the bottom of the carousel
    .carousel-control-prev and carousel-control-nextAdds left and right arrow buttons to the carousel for manual navigation
    .carousel-captionAdds a caption or description to each slide in the carousel
  • Slider Demo

    Bootstrap provides a few different options for styling Navigation slider. Some of examples are as shown below −

    ExampleDescriptionDownload link
    Slide menu on overThis example indicates about Slider Menu structure in BootstrapDownload
    Sub MenuThis example indicates about Slider Sub Menu structure in BootstrapDownload
    Sidebar With TabsThis example indicates about Slider With Tabs structure in BootstrapDownload
    TabsThis example indicates about Tabs structure in BootstrapDownload
  • Blog Demo

    What is a blog?

    A blog in Bootstrap refers to a blog website that is built using the Bootstrap framework for its layout, design, and responsive capabilities.

    A blog can be created using various Bootstrap components, such as the grid system for layout, navigation bars, cards, and responsive design classes to ensure the blog looks good on various devices and screen sizes.

  • Navigation Demo

    What is a navbar?

    The Bootstrap navbar is a responsive navigation header at the top of a webpage. It can expand or collapse based on the screen size, providing a user-friendly navigation experience for websites.

    Bootstrap provides built-in CSS classes to create a standard navigation bar.

    • The .navbar class is used to create a navigation bar component.
    • The .navbar-brand class represents the brand or logo of the website or application.
    • The .navbar-collapse class makes the navigation menu collapse into a dropdown or toggle button.
    • The .navbar-nav class is used to create a horizontal navigation menu with multiple navigation links or items.
    • The .nav-item class should be applied to each list item (<li>) within the navigation bar.
    • The .nav-link class is used to styled anchor tags (<a>) within a navigation component.
  • Buttons Demo

    Bootstrap provides some options to style buttons. Use utilities to design unique buttons for any application, which are summarized in the following table −

    Sr.No.Class & Description
    1btnDefault/ Standard button.
    2btn-primaryProvides extra visual weight and identifies the primary action in a set of buttons.
    3btn-successIndicates a successful or positive action.
    4btn-infoContextual button for informational alert messages.
    5btn-warningIndicates caution should be taken with this action.
    6btn-dangerIndicates a dangerous or potentially negative action.
    7btn-linkDeemphasize a button by making it look like a link while maintaining button behavior.

  • Grid Demo

    What is a Grid?

    In graphic design, a grid is a structure (usually two-dimensional) made up of a series of intersecting straight (vertical, horizontal) lines used to structure the content. It is widely used to design layout and content structure in print design. In web design, it is a very effective method to create a consistent layout rapidly and effectively using HTML and CSS.

    Working of Bootstrap Grid System

    Grid systems are used for creating page layouts through a series of rows and columns that house your content. Here’s how the Bootstrap grid system works −

    • Use rows to create horizontal groups of columns.
    • Content should be placed within the columns, and only columns may be the immediate children of rows.
    • Use the .themed-grid-col class to add some theming to the columns. This is not a default Bootstrap class.
    • Create a grid with equal columns using .row-cols-* classes.
    • Padding is used in columns to create gutters (gaps between column content). That padding is offset in rows using a negative margin on .rows for the first and last column.
    ExampleDescriptionDownload link
    GridsThis example indicates about grid structure in Bootstrap.Download
  • Visibility

    This chapter discusses about the visibilty utilities provided by Bootstrap. These utiltiy classes control the visibility of elements, without altering the display of the element.

    Following are the visibility classes provided by Bootstrap:

    • .visible – It is the default setting. The visible class shows data or visible data on the web page.
    • .invisible – It is used to hide or disappear the content of the application.

    The .invisible class will hide the elements both visually and for the assistive technology or screen reader users.

    Let us see an example for the utility classes .visible and .invisible:https://www.tutorialspoint.com/bootstrap/examples/visibility_utility.php

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Visibility</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"><h4 class="display-5 text-success">
    
          Visibility utility classes
      &lt;/h4&gt;&lt;/div&gt;&lt;div class="container mx-5 p-3"&gt;&lt;strong&gt;The utility classes that controls the visibility of the content on the webpage.&lt;/strong&gt;&lt;p class="visible text-bg-primary"&gt;
         The text on the webpage is visible due to the use of visibility class ".visible".
      &lt;/p&gt;&lt;p class="invisible"&gt;
        The text on the webpage is not visible due to the use of visibility class ".invisible".
      &lt;/p&gt;&lt;p class="text-bg-warning"&gt;This is the text that is without a visibility class usage.&lt;/p&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

  • Vertical align

    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:https://www.tutorialspoint.com/bootstrap/examples/vertical_align_inline.php

    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:https://www.tutorialspoint.com/bootstrap/examples/vertical_align_table.php

    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>

  • Text

    This chapter will discuss about common Bootstrap text utilities. You can customize text alignment, weight, line height, wrapping, font size, and other formatting options using Bootstrap utility classes.

    Text alignment

    Text alignment classes provide convenient ways to align text to different components. These classes include responsive options that align the text to the start, end, or center positions, using the same viewport width breakpoints as the grid system.

    Note: Kindly resize the browser to see the alignment of text relative to the specific viewport.https://www.tutorialspoint.com/bootstrap/examples/text_alignment.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="text-start text-info">Text aligned at starting position across all viewports sizes.</p><p class="text-center text-danger">Text aligned at center position across all viewports sizes.</p><p class="text-end text-warning">Text aligned at end position across all viewports sizes.</p><p class="text-sm-start text-primary">Text aligned at start on viewports sized SM (small) or wider.</p><p class="text-md-start text-primary">Text aligned at start on viewports sized MD (medium) or wider.</p><p class="text-lg-start text-primary">Text aligned at start on viewports sized LG (large) or wider.</p><p class="text-xl-start text-primary">Text aligned at start on viewports sized XL (extra-large) or wider.</p></body></html>

    Bootstrap does not provide utility classes for justified text, which means that while justified text may appear more visually appealing, it can make word spacing more random and consequently more difficult to read.

    Text wrapping and overflow

    To achieve text wrapping, apply the .text-wrap class to the text.https://www.tutorialspoint.com/bootstrap/examples/text_wrapping.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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="badge bg-warning text-wrap" style="width: 8rem;">
    
        This sentence should be wrapped.
      &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    You can stop text from wrapping by using the .text-nowrap class.https://www.tutorialspoint.com/bootstrap/examples/text_overflow.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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="text-nowrap bg-body-secondary border" style="width: 8rem;">
    
        This sentence should overflow the parent.
      &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Word break

    • To avoid breaking your components layout with long strings of text, use .text-break to apply word-wrap: break-word and word-break: break-word.
    • To enhance browser compatibility, use word-wrap instead of overflow-wrap. Additionally, include the deprecated word-break: break-word to prevent problems with flex containers.

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="text-break text-primary">TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT</p></body></html>

    Word breaking is not possible in Arabic, this is the most commonly used RTL language. The .text-break feature has been eliminated from our RTL compiled CSS

    Text transform

    Text capitalization classes can be used to convert text case in components.https://www.tutorialspoint.com/bootstrap/examples/text_transform.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="text-lowercase text-danger">This is a lower case text.</p><p class="text-uppercase text-info"> This is a upper case text.</p><p class="text-capitalize text-warning">This is a capitalized text.</p></body></html>

    Note how does the .text-capitalize class modifies the initial letter of every word, without changing the case of other letters.

    Font size

    • You can easily modify the font-size of text. Unlike heading classes (such as .h1.h6) that include font-weight and line-height, these utilities focus only on font-size.
    • The size of these utilities matches HTML's heading elements, with a decrease in size as the number increases.

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="fs-1 text-info">This is a text of .fs-1 font size.</p><p class="fs-2 text-info">This is a text of .fs-2 font size.</p><p class="fs-3 text-info">This is a text of .fs-3 font size.</p><p class="fs-4 text-info">This is a text of .fs-4 font size.</p><p class="fs-5 text-info">This is a text of .fs-5 font size.</p><p class="fs-6 text-info">This is a text of .fs-6 font size.</p></body></html>

    Modify the $font-sizes Sass map to customize the available font sizes.

    Font weight and italics

    Use the below utilities to change font-weight or font-style of text:

    1. font-weight utilities are abbreviated as .fw-*
    2. font-style utilities are abbreviated as .fst-*

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="fw-bold text-primary">This is a bold text.</p><p class="fw-bolder text-primary">This is a bolder weight text (relative to the parent element).</p><p class="fw-semibold text-primary">This is a semibold weight text.</p><p class="fw-medium text-secodary">This is a medium weight text.</p><p class="fw-normal text-secodary">This is a normal weight text.</p><p class="fw-light text-secodary">This is a light weight text.</p><p class="fw-lighter text-danger">This is a lighter weight text (relative to the parent element).</p><p class="fst-italic text-danger">This is a italic text.</p><p class="fst-normal text-danger">This is a text with normal font style.</p></body></html>

    Line height

    To change the height of the line, use .lh-* utility classes.https://www.tutorialspoint.com/bootstrap/examples/text_line_height.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="lh-1 text-primary">This is a long text that demonstrates how the utilities affect the line height of an element. Classes can be added to the element directly or occasionally to its parent element. With the help of utility API, these classes can be modified as required.</p><p class="lh-sm text-secondary">This is a long text that demonstrates how the utilities affect the line height of an element. Classes can be added to the element directly or occasionally to its parent element. With the help of utility API, these classes can be modified as required.</p><p class="lh-base text-warning">This is a long text that demonstrates how the utilities affect the line height of an element. Classes can be added to the element directly or occasionally to its parent element. With the help of utility API, these classes can be modified as required.</p><p class="lh-lg text-info">This is a long text that demonstrates how the utilities affect the line height of an element. Classes can be added to the element directly or occasionally to its parent element. With the help of utility API, these classes can be modified as required.</p></body></html>

    Monospace

    Convert the selected text to a monospace font stack using the .font-monospace class.https://www.tutorialspoint.com/bootstrap/examples/text_monospace.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="font-monospace text-primary">Text in monospace font.</p></body></html>

    Reset color

    Use the .text-reset class to restore the color of a text or link and allow it to inherit the color from its parent.https://www.tutorialspoint.com/bootstrap/examples/text_reset_color.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="text-body-danger">
    
        There is a &lt;a href="#" class="text-reset"&gt;reset link&lt;/a&gt; in this muted text.
      &lt;/p&gt;&lt;p class="text-body-secondary"&gt;
        There is a &lt;a href="#"&gt;reset link without text-reset class&lt;/a&gt; in this muted text.
      &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Text decoration

    Use text decoration classes to enhance the appearance of the text in components.https://www.tutorialspoint.com/bootstrap/examples/text_decoration.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Text</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 class="text-decoration-underline text-danger">There is a line underneath in this paragraph.</p><p class="text-decoration-line-through text-danger">A line runs through this text.</p><a href="#" class="text-decoration-none">There is no text decoration on this link.</a></body></html>

  • Spacing

    This chapter discusses about the utility classes provided by Bootstrap for spacing.

    Bootstrap provides predefined range of responsive margin, padding and gap utility classes that can be used to modify the appearance of an element. These utility classes work for all types of breakpoints, such as:

    breakpointsize
    xs
    sm>=576px
    md>=768px
    lg>=992px
    xl>=1200px
    xxl>=1400px

    The naming format of these classes is as follows:

    breakpointnaming format
    xs{property}{sides}-{size}
    sm, md, lg, xl, xxl{property}{sides}-{breakpoint}-{size}

    where property can be one of the following:

    propertyvalue
    mmargin
    ppadding

    where sides can be one of the following:

    sidevalue
    tmargin-top/padding-top
    bmargin-bottom/padding-bottom
    smargin-left/padding-left
    emargin-right/padding-right
    xmargin-left and margin-right or padding-left and padding-right
    ymargin-top and margin-bottom or padding-top and padding-bottom
    blankmargin and padding on all four sides

    where size can be one of the following:

    sizevalue
    0margin/padding – 0
    1margin/padding – 0.25rem
    2margin/padding – 0.5rem
    3margin/padding – 1rem
    4margin/padding – 1.5rem
    5margin/padding – 3rem
    automargin – auto

    Note: More sizes can be added by adding entries to the $spacers Sass map variable.

    Let us see an example for margin utilities:https://www.tutorialspoint.com/bootstrap/examples/spacing_margin_utilities.php

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Spacing</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-4">Spacing margin utilities</h4><p><u>Set the spacing (margin) of an element with the {property}{sides}-{breakpoint}-{size} classes.</u></p><div class="mt-4 bg-info">Only top margin (1.5rem)</div><div class="mb-5 bg-light">Only bottom margin (1rem)</div><div class="ms-5 bg-warning">Only left margin (3rem)</div><div class="me-5 bg-warning">Only right margin (3rem)</div><div class="mx-5 text-bg-secondary">Both left and right margins (3rem)</div><div class="my-5 bg-primary">Both top and bottom margins (3rem)</div></div></body></html>

    Let us see an example for padding utilities:https://www.tutorialspoint.com/bootstrap/examples/spacing_padding_utilities.php

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Spacing</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-4">Spacing padding utilities</h4><p><u>Set the spacing (padding) of an element with the {property){sides}-{breakpoint}-{size} classes.</u></p><div class="pt-4 bg-info">Only top padding (1.5rem)</div><div class="pb-5 text-bg-success">Only bottom padding (1rem)</div><div class="ps-5 bg-warning">Only left padding (3rem)</div><div class="pe-5 text-bg-danger">Only right padding (3rem)</div><div class="px-5 text-bg-secondary">Both left and right padding (3rem)</div><div class="py-5 text-bg-primary">Both top and bottom padding (3rem)</div></div></body></html>

    Horizontal centering

    For horizontal centering fixed-width block level content, Bootstrap provides .mx-auto class.

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

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Spacing</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">Horizontal centering</h4><br><div class="mx-auto p-2 text-bg-success" style="width: 200px;">
    
          Horizontally centered
        &lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>
    • By default, negative values can be used with margin properties in CSS.
    • The negative values cannot be used with padding.
    • It is possible to enable the negative margins by setting the variable $enable-negative-margins to true.

    Gap utilities

    You can make use of gap utilities on the parent element, while using display: grid or display: flex. By default the gap utilities are responsive.

    It can hold the values for all the six sizes from the $spacers map (0-5). There is no .gap-auto class, as it is same as .gap-0.

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

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Spacing</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-6">
    
          gap utility
      &lt;/h4&gt;&lt;h4&gt;gap utility class &lt;i&gt;.gap-*&lt;/i&gt;&lt;/h4&gt;&lt;div class="d-grid gap-0 p-3 border border-primary bg-light"&gt;&lt;div class="p-2 bg-light border"&gt;
              gap-0
          &lt;/div&gt;&lt;div class="p-2 bg-light border"&gt;
              gap-0
          &lt;/div&gt;&lt;/div&gt;&lt;div class="d-grid gap-1 p-3 border border-danger bg-primary-subtle"&gt;&lt;div class="p-2 bg-light border"&gt;
            gap-1
          &lt;/div&gt;&lt;div class="p-2 bg-light border"&gt;
            gap-1
          &lt;/div&gt;&lt;/div&gt;&lt;div class="d-grid gap-2 p-3 border border-success bg-danger-subtle"&gt;&lt;div class="p-2 bg-light border"&gt;
            gap-2
          &lt;/div&gt;&lt;div class="p-2 bg-light border"&gt;
            gap-2
          &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    row-gap

    In order to set the vertical space between children items in a specified container, use the utility class .row-gap.

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

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Spacing</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-6">
    
         gap utility
        &lt;/h4&gt;&lt;h4&gt;row gap utility class &lt;i&gt;.row-gap-*&lt;/i&gt;&lt;/h4&gt;&lt;div class="d-grid gap-0 row-gap-4"&gt;&lt;div class="p-2 border bg-primary"&gt;
            row gap-4
          &lt;/div&gt;&lt;div class="p-2 border bg-info"&gt;
            row gap-4
          &lt;/div&gt;&lt;div class="p-2 border bg-warning"&gt;
            row gap-4
          &lt;/div&gt;&lt;div class="p-2 border bg-danger-subtle"&gt;
            row gap-4
          &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    column-gap

    In order to set the horizontal space between children items in a specified container, use the utility class .column-gap.

    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 - Spacing</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-4">
    
        gap utility
      &lt;/h4&gt;&lt;h4&gt;column gap utility class &lt;i&gt;.column-gap-*&lt;/i&gt;&lt;/h4&gt;&lt;div class="d-flex gap-0 column-gap-4"&gt;&lt;div class="p-2 g-col-6 border border-primary"&gt;Grid item 1&lt;/div&gt;&lt;div class="p-2 g-col-6 border border-primary"&gt;Grid item 2&lt;/div&gt;&lt;div class="p-2 g-col-6 border border-primary"&gt;Grid item 3&lt;/div&gt;&lt;div class="p-2 g-col-6 border border-primary"&gt;Grid item 4&lt;/div&gt;&lt;/div&gt;&lt;div class="d-flex gap-0 column-gap-2"&gt;&lt;div class="p-2 g-col-6 border border-success"&gt;Grid item 1&lt;/div&gt;&lt;div class="p-2 g-col-6 border border-success"&gt;Grid item 2&lt;/div&gt;&lt;div class="p-2 g-col-6 border border-success"&gt;Grid item 3&lt;/div&gt;&lt;div class="p-2 g-col-6 border border-success"&gt;Grid item 4&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>