Author: saqibkhan

  • Breakpoint

    This chapter will discuss about Bootstrap breakpoints. Bootstrap breakpoints help us determine how a responsive layout is viewed on various devices and viewport sizes.

    Basic concepts

    • Breakpoints in Bootstrap are used to create responsive designs. You may adjust them at a particular viewport or device size.
    • CSS media queries allow us to customize styling based on browsers and operating sytem parameters. Media queries in Boostrap mostly use min-width to control the breakpoints.
    • Bootstrap’s goal is mobile-first, responsive designs. Bootstrap creates mobile-friendly layouts with minimal styles, adding layers for larger devices. It improves rendering time and gives users a better viewing experience.

    Types of breakpoints

    Bootstrap provides six default breakpoints referred to as grid tiers. These can be customized if we use Boostrap’s source Sass files.

    BreakpointClass InfixDimensions
    Extra smallNone<576px
    Smallsm576px
    Mediummd768px
    Largelg992px
    Extra largexl1200px
    Extra extra largexxl1400px

    These breakpoints cover common device sizes and viewport dimensions. These bootstrap breakpoints can be changed using Sass, as shown below:

      $grid-breakpoints: (
    
    xs: 0,
    sm: 576px,
    md: 768px,
    lg: 992px,
    xl: 1200px,
    xxl: 1400px
    );

    Media queries

    Bootstrap is developed to be mobile first, hence media queries are used to create wise breakpoints for its layouts and interfaces. Minimum viewport widths are used to control breakpoints which scale up elements as viewport changes.

    Min-width

    min-width media feature state specifies the minimum screen width of a specific device. Setting min-width in the breakpoints means CSS is only applied to devices whose width is greater than min-width of the device.

      @include media-breakpoint-up(sm) { ... }
    

    The above syntax means that CSS would be applied for devices larger than the min-width i.e Small devices (landscape phones, 576px and up).

    Let us see usage of min-width media feature with an example. Here you will see that we apply hide a div on devices width less than 768px.https://www.tutorialspoint.com/bootstrap/examples/breakpoints_min_width.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Breakpoint</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><style>
      .custom-class {
    
    display: none;
    } @media (min-width: 768px) {
    .custom-class {
      display: block;
    }
    @media (min-width: 768px) {
    .custom-class {
      display: block;
    }
    } </style></head><body><h5>This block is visible on all devices</h5><div class="container-fluid mt-2 "><div class="row"><div class="col-md-6 bg-warning p-3">
          md-6 warning
        &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;h5&gt;This block is not visible for sm breakpoint but visible for other breakpoints&lt;/h5&gt;&lt;div class="container-fluid mt-2 custom-class"&gt;&lt;div class="row"&gt;&lt;div class="col-md-6 bg-warning p-3"&gt;
          md-6 warning
        &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Max-width Breakpoint

    max-width media feature states the maximum screen width of a specific device. Setting max-width in the breakpoints means CSS is only applied to devices whose width is smaller than mentioned in the media query.

      @include media-breakpoint-down(xl) { ... }
    

    The above syntax means that CSS would be applied to large devices (desktops, less than 1200px).

    Let us see usage of max-width media feature with an example:https://www.tutorialspoint.com/bootstrap/examples/breakpoints_max_width.php

    Example

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

    <!DOCTYPE html><html lang="en"><head><title>Bootstrap - Breakpoint</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><style>
    .custom-class {
      display: none;
    }
    @media (max-width: 767.98px) {
      .custom-class {
    
    display: block;
    } } </style></head><body><h5>This block visible on all devices</h5><div class="container-fluid mt-2"><div class="row"><div class="col-xxl-3 bg-primary text-black p-3">
        xxl-3 primary
      &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h5&gt;This block not visible all devices larger than sm&lt;/h5&gt;&lt;div class="container-fluid mt-2 custom-class"&gt;&lt;div class="row"&gt;&lt;div class="col-lg-6  bg-warning text-black p-3"&gt;
        lg-6 warning
      &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Single Breakpoint

    Single breakpoint means targeting a specific screen sizes using minimum and maximum breakpoint widths in media queries.

      @include media-breakpoint-only(md) { ... }
    

    The above syntax means that CSS would be applied for devices with screen sizes between @media (min-width: 768px) and (max-width: 991.98px) { ... } (i.e medium sized devices such as tablets, desktops)

    Between Breakpoints

    Between breakpoints target multiple breakpoints.

      @include media-breakpoint-between(md, xl) { ... }
    

    Above syntax results in @media (min-width: 892px) and (max-width: 1278px) { ... }, which means styles are applied starting from medium devices and up to extra large devices.

  • Color modes

    This chapter discusses about the color modes supported by Bootstrap. The different color modes available are:

    • light mode (default)
    • dark mode (new)
    • create your own custom template

    Dark mode

    With v5.3.0, a new color mode is introduced, i.e. the dark mode. Toggling of color modes on <html> element or on any specific components and elements is allowed, using the data-bs-theme attribute.

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

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Color modes</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script></head><body><h1 class="text-center">Color mode - dark</h1><center><div class="dropdown" data-bs-theme="light"><button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButtonLight" data-bs-toggle="dropdown" aria-expanded="false">
    
    			  Light mode dropdown
    			&lt;/button&gt;&lt;ul class="dropdown-menu" aria-labelledby="dropdownMenuButtonLight"&gt;&lt;li&gt;&lt;a class="dropdown-item active" href="#"&gt;Item 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Item 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Item 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Item 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;hr class="dropdown-divider"&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Total items&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="dropdown" data-bs-theme="dark"&gt;&lt;button class="btn btn-danger dropdown-toggle" type="button" id="dropdownMenuButtonDark" data-bs-toggle="dropdown" aria-expanded="false"&gt;
    			  Dark mode dropdown
    			&lt;/button&gt;&lt;ul class="dropdown-menu" aria-labelledby="dropdownMenuButtonDark"&gt;&lt;li&gt;&lt;a class="dropdown-item active" href="#"&gt;Item 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Item 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Item 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Item 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;hr class="dropdown-divider"&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="dropdown-item" href="#"&gt;Total items&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/center&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Overview

    • Color mode styles are controlled by the data-bs-theme attribute.
    • The data-bs-theme atrribute can be applied on <html> element or any other component or element.
    • If applied on <html> element, it will apply to everything under the scope of <html> element.
    • If applied to a specific component or element, it will be scoped to that particular component or element.
    • You will have to add new overrides for the shared global CSS variables, for each color mode you want to support. Use the following mixin to write the color mode specific style:

    Usage

    Enable dark mode

    You can enable the dark mode across your project by adding data-bs-theme="dark" attribute to the <html> element. This setting will be applied to all the components and elements, except for those that have a different value for data-bs-theme.

    This can be achieved by the following code:

    <!DOCTYPE html><html lang="en" data-bs-theme="dark"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Bootstrap color mode</title><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous"></head><body><h1>Hello, world!</h1><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script></body></html>

    Custom color modes

    Apart from light and dark mode, you can also create your own custom color mode. You can create your own data-bs-theme selector with a custom value, and modidy the Sass and CSS variables.

    Toggle between color modes

    You can switch or toggle between the dark and light mode using CSS and JavaScript. Here is an example shown below:https://www.tutorialspoint.com/bootstrap/examples/color_mode_toggle.php

    Example

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

    <!DOCTYPE html><html><head><title>Bootstrap - Color modes</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><style>
    
        body {
        padding: 25px;
        background-color: white;
        color: black;
        font-size: 25px;
        }
        .dark-mode {
        background-color: black;
        color: white;
        }
    &lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h2&gt;Toggle Dark/Light Mode&lt;/h2&gt;&lt;p&gt;Click the button to toggle between dark and light mode for this page.&lt;/p&gt;&lt;button onclick="myFunction()"&gt;Toggle dark mode&lt;/button&gt;&lt;script&gt;
        function myFunction() {
        var element = document.body;
        element.classList.toggle("dark-mode");
        }
        &lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Print Page

  • CSS variables

    This chapter discusses about all the CSS variables provided by Bootstrap, that help in fast and customized design and development of applications.

    The compiled CSS of Bootstrap consists of a plethora of CSS custom properties (variables) that allow for instant customization without the need to recompile Sass, wherein commonly used values such as theme colors, breakpoints, and primary font stacks are easily accessible during browser inspection, code sandbox operation, or general prototyping.

    All the custom variables provided by Bootstrap are prefixed with bs-, so that there is no conflict with any other third-party CSS.

    Root variables

    Root variables are the variables that can be accessed from anywhere, Bootstraps CSS is loaded. These variables are located in the _root.scss file and also included in the compiled dist files

    Default variables

    The CSS variables that are accessible everywhere, irrespective of the color mode, are the default variables.

        :root,
    
    [data-bs-theme=light] {
    --bs-blue: #0d6efd;
    --bs-indigo: #6610f2;
    --bs-purple: #6f42c1;
    --bs-pink: #d63384;
    --bs-red: #dc3545;
    --bs-orange: #fd7e14;
    --bs-yellow: #ffc107;
    --bs-green: #198754;
    --bs-teal: #20c997;
    --bs-cyan: #0dcaf0;
    --bs-black: #000;
    --bs-white: #fff;
    --bs-gray: #6c757d;
    --bs-gray-dark: #343a40;
    --bs-gray-100: #f8f9fa;
    --bs-gray-200: #e9ecef;
    --bs-gray-300: #dee2e6;
    --bs-gray-400: #ced4da;
    --bs-gray-500: #adb5bd;
    --bs-gray-600: #6c757d;
    --bs-gray-700: #495057;
    --bs-gray-800: #343a40;
    --bs-gray-900: #212529;
    --bs-primary: #0d6efd;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;
    --bs-primary-rgb: 13, 110, 253;
    --bs-secondary-rgb: 108, 117, 125;
    --bs-success-rgb: 25, 135, 84;
    --bs-info-rgb: 13, 202, 240;
    --bs-warning-rgb: 255, 193, 7;
    --bs-danger-rgb: 220, 53, 69;
    --bs-light-rgb: 248, 249, 250;
    --bs-dark-rgb: 33, 37, 41;
    --bs-primary-text-emphasis: #052c65;
    --bs-secondary-text-emphasis: #2b2f32;
    --bs-success-text-emphasis: #0a3622;
    --bs-info-text-emphasis: #055160;
    --bs-warning-text-emphasis: #664d03;
    --bs-danger-text-emphasis: #58151c;
    --bs-light-text-emphasis: #495057;
    --bs-dark-text-emphasis: #495057;
    --bs-primary-bg-subtle: #cfe2ff;
    --bs-secondary-bg-subtle: #e2e3e5;
    --bs-success-bg-subtle: #d1e7dd;
    --bs-info-bg-subtle: #cff4fc;
    --bs-warning-bg-subtle: #fff3cd;
    --bs-danger-bg-subtle: #f8d7da;
    --bs-light-bg-subtle: #fcfcfd;
    --bs-dark-bg-subtle: #ced4da;
    --bs-primary-border-subtle: #9ec5fe;
    --bs-secondary-border-subtle: #c4c8cb;
    --bs-success-border-subtle: #a3cfbb;
    --bs-info-border-subtle: #9eeaf9;
    --bs-warning-border-subtle: #ffe69c;
    --bs-danger-border-subtle: #f1aeb5;
    --bs-light-border-subtle: #e9ecef;
    --bs-dark-border-subtle: #adb5bd;
    --bs-white-rgb: 255, 255, 255;
    --bs-black-rgb: 0, 0, 0;
    --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-font-size: 1rem;
    --bs-body-font-weight: 400;
    --bs-body-line-height: 1.5;
    --bs-body-color: #212529;
    --bs-body-color-rgb: 33, 37, 41;
    --bs-body-bg: #fff;
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-emphasis-color: #000;
    --bs-emphasis-color-rgb: 0, 0, 0;
    --bs-secondary-color: rgba(33, 37, 41, 0.75);
    --bs-secondary-color-rgb: 33, 37, 41;
    --bs-secondary-bg: #e9ecef;
    --bs-secondary-bg-rgb: 233, 236, 239;
    --bs-tertiary-color: rgba(33, 37, 41, 0.5);
    --bs-tertiary-color-rgb: 33, 37, 41;
    --bs-tertiary-bg: #f8f9fa;
    --bs-tertiary-bg-rgb: 248, 249, 250;
    --bs-heading-color: inherit;
    --bs-link-color: #0d6efd;
    --bs-link-color-rgb: 13, 110, 253;
    --bs-link-decoration: underline;
    --bs-link-hover-color: #0a58ca;
    --bs-link-hover-color-rgb: 10, 88, 202;
    --bs-code-color: #d63384;
    --bs-highlight-bg: #fff3cd;
    --bs-border-width: 1px;
    --bs-border-style: solid;
    --bs-border-color: #dee2e6;
    --bs-border-color-translucent: rgba(0, 0, 0, 0.175);
    --bs-border-radius: 0.375rem;
    --bs-border-radius-sm: 0.25rem;
    --bs-border-radius-lg: 0.5rem;
    --bs-border-radius-xl: 1rem;
    --bs-border-radius-xxl: 2rem;
    --bs-border-radius-2xl: var(--bs-border-radius-xxl);
    --bs-border-radius-pill: 50rem;
    --bs-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --bs-box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --bs-box-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075);
    --bs-focus-ring-width: 0.25rem;
    --bs-focus-ring-opacity: 0.25;
    --bs-focus-ring-color: rgba(13, 110, 253, 0.25);
    --bs-form-valid-color: #198754;
    --bs-form-valid-border-color: #198754;
    --bs-form-invalid-color: #dc3545;
    --bs-form-invalid-border-color: #dc3545;
    }

    Dark mode variables

    Following variables are limited to the built-in dark mode of Bootstrap:

        [data-bs-theme=dark] {
    
        color-scheme: dark;
        --bs-body-color: #adb5bd;
        --bs-body-color-rgb: 173, 181, 189;
        --bs-body-bg: #212529;
        --bs-body-bg-rgb: 33, 37, 41;
        --bs-emphasis-color: #fff;
        --bs-emphasis-color-rgb: 255, 255, 255;
        --bs-secondary-color: rgba(173, 181, 189, 0.75);
        --bs-secondary-color-rgb: 173, 181, 189;
        --bs-secondary-bg: #343a40;
        --bs-secondary-bg-rgb: 52, 58, 64;
        --bs-tertiary-color: rgba(173, 181, 189, 0.5);
        --bs-tertiary-color-rgb: 173, 181, 189;
        --bs-tertiary-bg: #2b3035;
        --bs-tertiary-bg-rgb: 43, 48, 53;
        --bs-primary-text-emphasis: #6ea8fe;
        --bs-secondary-text-emphasis: #a7acb1;
        --bs-success-text-emphasis: #75b798;
        --bs-info-text-emphasis: #6edff6;
        --bs-warning-text-emphasis: #ffda6a;
        --bs-danger-text-emphasis: #ea868f;
        --bs-light-text-emphasis: #f8f9fa;
        --bs-dark-text-emphasis: #dee2e6;
        --bs-primary-bg-subtle: #031633;
        --bs-secondary-bg-subtle: #161719;
        --bs-success-bg-subtle: #051b11;
        --bs-info-bg-subtle: #032830;
        --bs-warning-bg-subtle: #332701;
        --bs-danger-bg-subtle: #2c0b0e;
        --bs-light-bg-subtle: #343a40;
        --bs-dark-bg-subtle: #1a1d20;
        --bs-primary-border-subtle: #084298;
        --bs-secondary-border-subtle: #41464b;
        --bs-success-border-subtle: #0f5132;
        --bs-info-border-subtle: #087990;
        --bs-warning-border-subtle: #997404;
        --bs-danger-border-subtle: #842029;
        --bs-light-border-subtle: #495057;
        --bs-dark-border-subtle: #343a40;
        --bs-heading-color: inherit;
        --bs-link-color: #6ea8fe;
        --bs-link-hover-color: #8bb9fe;
        --bs-link-color-rgb: 110, 168, 254;
        --bs-link-hover-color-rgb: 139, 185, 254;
        --bs-code-color: #e685b5;
        --bs-border-color: #495057;
        --bs-border-color-translucent: rgba(255, 255, 255, 0.15);
        --bs-form-valid-color: #75b798;
        --bs-form-valid-border-color: #75b798;
        --bs-form-invalid-color: #ea868f;
        --bs-form-invalid-border-color: #ea868f;
      }

    Component variables

    The usage of custom properties as local variables for various components is becoming more prevalent in Bootstrap 5. This results in a reduction of compiled CSS, prevents styles from being inherited in nested tables, and permits some customization and expansion of Bootstrap components following Sass compilation.

    CSS variables are distinctively used in navbarsgrids and many more. When CSS variables are assigned at base component level, it becomes easier to customize and modify it later.

    Prefix

    A prefix is used with most of the variables, in order to prevent any collisions with your own codebase. Every CSS variable requires , apart from the prefix.

    You can customize the prefix, using the $prefix Sass variable. It is set to bs-, by default.

    Examples

    CSS variables provide comparable adaptability to Sass variables; however, there is no requirement for compilation before transmitting to the browser. As an illustration, we utilize CSS variables to reset our page’s font and link styles:

        body {
    
        font: 1rem/1.5 var(--bs-font-monospace);
    }
    a {
        color: var(--bs-red);
    }

    Focus variables

    By employing a blend of Sass and CSS variables, Bootstrap enables the provision of personalized :focus styles that can be selectively appended to singular components and elements. Nevertheless, the overriding of all :focus styles across the board is not currently implemented.

    Default values can be set in the Sass, that can be customized before compiling.

    scss/_variables.scss
    
    $focus-ring-width:      .25rem;
    $focus-ring-opacity:    .25;
    $focus-ring-color:      rgba($primary, $focus-ring-opacity);
    $focus-ring-blur:       0;
    $focus-ring-box-shadow: 0 0 $focus-ring-blur $focus-ring-width $focus-ring-color;

    The variables are subsequently assigned to CSS variables at the :root level, which can be customized in real-time and feature options for x and y offsets, with their default fallback value being 0.

    scss/_root.scss
    
    --#{$prefix}focus-ring-width: #{$focus-ring-width};
    --#{$prefix}focus-ring-opacity: #{$focus-ring-opacity};
    --#{$prefix}focus-ring-color: #{$focus-ring-color};

    Grid breakpoints

    Grid breakpoints, such as md, lg, xl, xxl are included as CSS variables (except for xs). CSS variables can not be used in media queries.

  • RTL

    This chapter discusses about RTL (right to left) support provided by Bootstrap. The RTL feature supports for right-to-left text across your layout, components and utilities.

    Requirements

    To enable RTL in pages powered by Bootstrap, you must fulfill the two requirements. They are as follows:

    • On <html> element, set dir-“rtl”.
    • On <html> element, add an appropriate lang attribute, such as lang=”ar”.

    You need to include the RTL version of CSS. For example, here is a stylesheet with RTL enabled:

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.rtl.min.css" integrity="sha384-PJsj/BTMqILvmcej7ulplguok8ag4xFTPryRq8xevL7eBYSmpXKcbNVuy+P0RMgq" crossorigin="anonymous">

    Starter template

    Following is a sample of starter template meeting the requirements for enabling RTL:https://www.tutorialspoint.com/bootstrap/examples/rtl_template.php

    Example

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

    <!DOCTYPE html><html lang="ar" dir="rtl"><head><!-- Required meta tags --><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><!-- Bootstrap CSS --><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.rtl.min.css" integrity="sha384-PJsj/BTMqILvmcej7ulplguok8ag4xFTPryRq8xevL7eBYSmpXKcbNVuy+P0RMgq" crossorigin="anonymous"><!--"Welcome to Tutorialspoint" written in arabic--><title>   Tutorialspoint</title></head><body><!--"Welcome to Tutorialspoint" written in arabic--><h1>   Tutorialspoint</h1><!-- Optional JavaScript; choose one of the two! --><!-- Option 1: Bootstrap Bundle with Popper --><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script><!-- Option 2: Separate Popper and Bootstrap JS --><!--
       <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
       <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-fbbOQedDUMZZ5KreZpsbe1LCZPVmfTnH7ois6mU1QK+m14rQ1l2bGBq41eYeM/fS" crossorigin="anonymous"></script>
       --></body></html>

    Customize from source

    Use the variables, maps and mixins, for customization purposes. The approach works exactly like LTR, for RTL.

    Custom RTL values

    There are certain directives for RTL CSS values, via which you can set the output of a variable different for RTL. For an example, in order to decrease the font weight throughout your codebase, you can use the syntax as /*rtl: {value}*/.

    $font-weight-bold: 600 #{/* rtl:500 */} !default;
    

    This would output to the following for default CSS and RTL CSS:

    /* bootstrap.css */
    dt {
       font-weight: 600 /* rtl:500 */; 
    }
    
    /* bootstrap.rtl.css */
    dt {
       font-weight: 500;
    }
    

    Alternative font stack

    You should be aware that not all the non-Latin alphabets are supported. Hence in order to switch from Pan-European to Arabic family of fonts, you may need to use /*rtl:insert: {value}*/ in your font stack to alter the names of font families.

    To switch from Helvetica Neue font for LTR to Helvetica Neue Arabic for RTL, your Sass code could look like this:

    $font-family-sans-serif:
    Helvetica Neue #{"/* rtl:insert:Arabic */"},
    
    // Cross-platform generic font family (default user interface font)
    system-ui,
    
    // Safari for macOS and iOS (San Francisco)
    -apple-system,
    
    // Chrome < 56 for macOS (San Francisco)
    BlinkMacSystemFont,
    
    // Windows
    "Segoe UI",
    
    // Android
    Roboto,
    
    // Basic web fallback
    Arial,
    
    // Linux
    "Noto Sans",
    
    // Sans serif fallback
    sans-serif,
    
    // Emoji fonts
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
    

    RTL and LTR at the same time

    Do you want to use LTR and RTL together? Its very much possible, you just need to wrap your @imports with a class, and set a custom rename rule for RTLCSS:

    /* rtl:begin:options: {
       "autoRename": true,
       "stringMap":[ {
    
      "name": "ltr-rtl",
      "priority": 100,
      "search": ["ltr"],
      "replace": ["rtl"],
      "options": {
         "scope": "*",
         "ignoreCase": false
      }
    } ] } */ .ltr { @import "../node_modules/bootstrap/scss/bootstrap"; } /*rtl:end:options*/

    Each selector in your CSS files will have the prefix .ltr (or .rtl for RTL files) after executing Sass and RTLCSS. Now that both files can be used on the same page, you can use either the .ltr or .rtl component wrapper extension to specify which direction to utilise.

    While working with LTR and RTL implementation together, you need to consider the following points:

    1. Make sure to add dir and lang attributes accordingly, when switching .ltr and .rtl
    2. Try to do some customization and load one of the two files (ltr & rtl) asynchronously, as loading of both the files can cause performance issues.
    3. Nesting styles will prevent the form-validation-state() mixin and it may not work as intended.

    The Breadcrumb case

    The only case that requires its own brand-new variable is the breadcrumb separator, namely $breadcrumb-divider-flipped, defaulting to $breadcrumb-divider.

  • Environment Setup

    It is very easy to setup and start using Bootstrap. This chapter will explain how to download and setup Bootstrap 5.3. We will also discuss the Bootstrap file structure, and demonstrate its usage with an example.

    There are two ways to do the environment Setup in Bootstrap 5.3.

    • Compiled CSS and JS
    • Source Files

    Following sections will discuss about these two steps.

    Compiled CSS and JS

    You can download ready to use compiled code of Bootstrap v5.3.0 here

    Once downloaded, unzip the compressed folder and we see the following folder structure:

      bootstrap/
     css/
    
    bootstrap-grid.css
    bootstrap-grid.css.map
    bootstrap-grid.min.css
    bootstrap-grid.min.css.map
    bootstrap-grid.rtl.css
    bootstrap-grid.rtl.css.map
    bootstrap-grid.rtl.min.css
    bootstrap-grid.rtl.min.css.map
    bootstrap-reboot.css
    bootstrap-reboot.css.map
    bootstrap-reboot.min.css
    bootstrap-reboot.min.css.map
    bootstrap-reboot.rtl.css
    bootstrap-reboot.rtl.css.map
    bootstrap-reboot.rtl.min.css
    bootstrap-reboot.rtl.min.css.map
    bootstrap-utilities.css
    bootstrap-utilities.css.map
    bootstrap-utilities.min.css
    bootstrap-utilities.min.css.map
    bootstrap-utilities.rtl.css
    bootstrap-utilities.rtl.css.map
    bootstrap-utilities.rtl.min.css
    bootstrap-utilities.rtl.min.css.map
    bootstrap.css
    bootstrap.css.map
    bootstrap.min.css
    bootstrap.min.css.map
    bootstrap.rtl.css
    bootstrap.rtl.css.map
    bootstrap.rtl.min.css
    bootstrap.rtl.min.css.map
    js/
     bootstrap.bundle.js
     bootstrap.bundle.js.map
     bootstrap.bundle.min.js
     bootstrap.bundle.min.js.map
     bootstrap.esm.js
     bootstrap.esm.js.map
     bootstrap.esm.min.js
     bootstrap.esm.min.js.map
     bootstrap.js
     bootstrap.js.map
     bootstrap.min.js
     bootstrap.min.js.map

    This compressed folder contains:

    • Compiled and minified CSS bundles: Bundles of compiled and minified CSS (view a comparison of CSS files)
    • Compiled and minified JavaScript plugins: JavaScript plugins that have been minified and compiled (view a JS files comparison)

    Documentation, source code, and any extra JavaScript dependencies like Popper are not included.

    Source files

    You can download Bootstrap source files by clicking on the download link on official site here, or you can also use the GitHub link to start downloading . You will get the Bootstrap v5.3.0 after this download.

    Download Sass, JavaScript, and documentation files to customizeBootstrap using your asset pipeline. Extra tools are needed for this option.

    • For converting Sass source files into CSS files, use the Saas compiler.
    • Autoprefixer for CSS vendor prefixing

    CDN via jsDelivr

    CDN (Content Delivery Network) is a free content delivery platform offered by Bootstrap. Predefined files of CSS and JS can be used without installing them in your local system using the Bootstrap CDN. You can use available Bootstrap codes by copying the link and adding them to your project.

    The only condition to use the CDN is to have internet connectivity in your local system. Developers can access the complete CSS for Bootstrap CDN via jsDelivr by copying the below link:.

    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>

    It is advised to add Popper before JS, preferably via CDN:

    <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-fbbOQedDUMZZ5KreZpsbe1LCZPVmfTnH7ois6mU1QK+m14rQ1l2bGBq41eYeM/fS" crossorigin="anonymous"></script>

    Package managers

    We can also install Bootstrap into the local system using Package Manager. Let’s see the commands to install Bootstrap.

    Package ManagerDescriptionCommands to install
    npmInstall Bootstrap in your Node.js powered apps with the npm package:$ npm install [email protected]
    yarnInstall Bootstrap in your Node.js powered apps with the yarn package:$ yarn add [email protected]
    RubyGemsInstall Bootstrap in your Ruby apps using Bundler (recommended) and RubyGems by adding the following line to your Gemfile:gem ‘bootstrap’, ‘~> 5.3.0’
    OR
    $ gem install bootstrap -v 5.3.0
    ComposerYou can also install and manage Bootstraps Sass and JavaScript using Composer:$ composer require twbs/bootstrap:5.3.0
    NuGetIf you develop in .NET Framework, you can also install and manage Bootstraps CSS or Sass and JavaScript using NuGet.Step1: PM> Install-Package bootstrap
    Step2: PM> Install-Package bootstrap.sass

    HTML Template

    A basic HTML template using Bootstrap 5.3 would look like this −

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

    <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Bootstrap demo</title><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous"></head><body><h1>Welcome to Tutorialspoint!</h1><script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script></body></html>

    Here you can see the popper.min.jsbootstrap.bundle.min.js and bootstrap.min.css files that are included to make a normal HTM file to the Bootstrapped Template.

  • Overview

    Bootstrap

    Bootstrap is a popular open-source front-end framework that is used to create responsive and mobile-first websites and web applications.

    It provides a collection of CSS and JavaScript components, such as grids, forms, buttons, navigation bars, and more, which can be easily implemented and customized to create responsive and visually appealing web interfaces.

    With Bootstrap, developers can save time and effort by utilizing pre-designed components, as well as the grid system for creating responsive layouts. It also provides numerous styling options and utilities to enhance the overall appearance and functionality of websites. Bootstrap is widely used by web developers to streamline the web development process and create consistent and visually appealing user interfaces.

    History of Bootstrap

    Mark Otto and Jacob Thornton developed the Bootstrap, at Twitter. In August 2011, Bootstrap was released as an open source product, on GitHub.

    Key points in Bootstrap 5 and later versions

    There are several new features and changes in Bootstrap 5 compared to Bootstrap 4. Some of the notable ones include:

    1. Smaller file size: Bootstrap 5.* is designed to be more lightweight, with the removal of jQuery and other dependencies. It has switched to Vanilla JavaScript. This leads to faster load times.
    2. Improved grid system: The grid system in Bootstrap 5.* comes with a new, more flexible layout. It introduces a new gap utility and no longer relies on floats.
    3. Updated default colors and theming: Bootstrap 5.* introduces a new default color palette and theme. The new colors are more modern and visually appealing.
    4. Improved form controls: The form controls in Bootstrap 5.* have been enhanced with new styles and options. There are new styles for checkboxes and radio buttons, as well as improved custom select menus.
    5. New helpers and utilities: Bootstrap 5.* introduces new utility classes and helpers, such as vertical centering, stretched link utility, and more.
    6. Improved documentation and accessibility: The documentation for Bootstrap 5 has been updated and improved, making it easier to use and understand. Additionally, Bootstrap 5 focuses more on accessibility, with better ARIA support and improved keyboard navigation.

    Bootstrap – advantages

    There are several benefits of using Bootstrap:

    1. Responsive design: Bootstrap is built with a mobile-first approach, meaning it is designed to be responsive and adapt to different screen sizes. This ensures that your mobile application looks good and functions well on various devices, including smartphones and tablets.
    2. Time-saving: Bootstrap provides a wide range of predefined and customizable CSS and JavaScript components, such as grids, buttons, navigation bars, and modals. These ready-to-use components help developers save time and effort by eliminating the need to code everything from scratch.
    3. Consistent appearance: With Bootstrap, you can achieve a consistent and professional-looking design across your mobile application. It offers a set of predefined styles and themes that can be easily customized to match your brand’s identity.
    4. Cross-browser compatibility: Bootstrap is designed to work well across different web browsers, ensuring that your mobile application functions consistently for users, regardless of the browser they prefer to use.
    5. Community and support: Bootstrap has a large and active community of developers who contribute to its improvement and provide support through forums and online resources. This can be helpful if you encounter any challenges or have questions during the development of your mobile application.
    6. Accessibility: Bootstrap follows modern web development standards and best practices, including accessibility guidelines. This ensures that your mobile application is accessible to users with disabilities, enhancing its usability and reach.
    7. Continuous updates and enhancements: Bootstrap is regularly updated and improved with new features, bug fixes, and performance enhancements. By using Bootstrap, you can take advantage of these updates to keep your mobile application up-to-date and optimized.

    Bootstrap – important globals

    Let’s examine how Bootstrap utilizes a limited number of crucial global styles and settings that are primarily focused on normalizing cross-browser styles.

    HTML5 doctype

    HTML5 doctype is crucial to be used, without which the styling will be incomplete and inappropriate.

    For LTR direction:

    <!DOCTYPE html><html lang="en">
    
      ...
    &lt;/html&gt;</pre>

    For RTL direction:

    <!DOCTYPE html><html lang="ar" dir="rtl">
    
      ...
    &lt;/html&gt;</pre>

    Viewport meta

    Bootstrap follows a "mobile-first" development approach, where the code is initially optimized for mobile devices, and then components are scaled up as needed through CSS media queries. To ensure accurate rendering and touch zooming on all devices, it's essential to include the responsive viewport meta tag in the <head> section of your webpage.

    <meta name="viewport" content="width=device-width, initial-scale=1">

    Box-sizing

    The global box-sizing value is switched from content-box to border-box, for extensive sizing in CSS. It ensures that the final width of an element is not affected by the padding.

    The following code will let all the nested elements, including the ones with generated content via ::before and ::after, inherit the specified box-sizing for that .selector-for-some-widget:

        .selector-for-some-widget {
    
        box-sizing: content-box;
      }

    Reboot

    In order to correct the inconsistencies across various browsers and devices, use reboot. This will improve the cross-browser rendering.

    Use of CDN

    CDN, Content Delivery Network, is a network of servers that speeds up the loading of webpages for data-heavy applications.

    How to use Bootstrap CDN?

    Follow the steps given below:

    1. Build a basic HTML file - Use your preferred code editor to create the file
    2. Convert the file to a Bootstrap template - Include the Bootstrap CSS CDN and Bootstrap JS CDN files, along with Popper and Bootstrap jQuery through their CDN links
    3. Save and view the file - Save the file with extension .html and as a template.
  • SQL Dialects

    Each RDBMS has its own “dialect” of SQL:

    • T-SQL → Microsoft SQL Server
    • PL/SQL → Oracle
    • pgSQL → PostgreSQL
    • MySQL SQL → MySQL flavor
      The basics remain the same, but advanced features may differ.
  • Supported by All Major Databases

    SQL is supported by almost every major RDBMS (Relational Database Management System) like:

    • MySQL
    • PostgreSQL
    • Oracle Database
    • Microsoft SQL Server
    • SQLite
      Despite slight differences in syntax, all use SQL as the base language.
  • Set-Based Operations

    SQL is set-based rather than row-based. Instead of looping through individual rows, SQL handles groups (or sets) of rows at once. For example, finding the average salary of all employees takes just one query using AVG().

  • Case-Insensitivity

    SQL commands are not case-sensitive. For example:

    SELECT name FROM students;
    select name from students;
    SeLeCt name FROM students;
    

    All three queries will give the same result.