Bootstrap · CSS framework

On this page 7

Bootstrap is an open-source CSS framework that provides a ready-made responsive grid system, a library of styled interface components and hundreds of utility classes, so developers can assemble consistent web pages without writing most of the CSS themselves. Originally created at Twitter and released publicly in 2011, it became one of the most widely deployed front-end toolkits on the web.

In CSS practice, Bootstrap sits between hand-written stylesheets and fully custom design systems. It is distributed as compiled CSS, as Sass source files for customization and as an optional JavaScript bundle that powers interactive components such as modals, dropdowns and carousels. The current major version, Bootstrap 5, dropped the jQuery dependency and added CSS custom properties and an extensive utility API.

How the Bootstrap framework is structured

Bootstrap is organized into layered modules that build on each other, from global resets up to complete components. At the base, a stylesheet called Reboot normalizes browser defaults, sets the box-sizing model to border-box and establishes typography. On top of that sit the layout system, the content styles, the components and finally the utilities, which are designed to override everything else.

The following table summarizes the main layers of the framework and what each one contributes to a page.

LayerWhat it providesTypical classes
RebootConsistent baseline across browsersApplied to elements, no classes
LayoutContainers, grid rows and columnscontainer, row, col-md-6
ContentTypography, tables, images, figureslead, table-striped, img-fluid
ComponentsButtons, cards, navbars, modals, alertsbtn, card, navbar, modal
UtilitiesSingle-purpose spacing, color and display rulesmt-3, d-flex, text-center
JavaScript pluginsBehavior for interactive componentsdata-bs-toggle attributes
Main layers of the Bootstrap framework

Because components rely on predictable class names, a developer can write semantic HTML, add documented classes and obtain a styled result immediately. The trade-off is that markup becomes tightly coupled to the framework, which matters later when a project migrates away from it.

The Bootstrap grid and breakpoints

The Bootstrap grid is a 12-column layout system built on Flexbox that adapts column widths to the viewport through predefined breakpoints. A row contains columns whose classes declare how many of the 12 units they occupy at each screen size, for example a column that spans the full width on phones and half the width from the medium breakpoint upward.

The grid is mobile-first: a class without a breakpoint infix applies to all sizes, and each larger infix overrides it from that minimum width upward through a media query. The default breakpoints in Bootstrap 5 are listed below.

BreakpointClass infixMinimum widthTypical devices
Extra smallnoneless than 576 pxPortrait phones
Smallsm576 pxLandscape phones
Mediummd768 pxTablets
Largelg992 pxLaptops
Extra largexl1200 pxDesktops
Extra extra largexxl1400 pxWide desktop screens
Default breakpoints in Bootstrap 5

Columns are separated by gutters, which Bootstrap 5 implements with padding and negative margins controlled by gutter classes such as g-3. Containers either have fixed maximum widths per breakpoint or stretch fluidly with container-fluid. Since version 5.1, an opt-in CSS grid mode is also available, but the Flexbox grid remains the default.

Customizing Bootstrap with Sass and CSS variables

Bootstrap is customized mainly by overriding Sass variables and maps before the framework is compiled, which changes colors, spacing, breakpoints and component defaults at the source. Teams that import the Sass files can also include only the modules they need, which substantially reduces the size of the final stylesheet.

  • Sass variables such as $primary or $border-radius change design tokens globally at build time.
  • Sass maps such as $theme-colors add or remove whole color variants and generate matching classes.
  • CSS custom properties prefixed with --bs- allow runtime theming, including the color modes for light and dark themes added in version 5.3.
  • The utility API generates new utility classes or removes unused ones from a single configuration map.

Loading the precompiled CSS from a CDN is the fastest way to start but gives the least control: every component ships, and theming is limited to CSS variable overrides. For production work, a build step with Sass and unused-CSS removal usually brings the stylesheet from roughly 200 KB unminified to a fraction of that.

Bootstrap compared with other CSS approaches

Bootstrap is a component-first framework, which distinguishes it from utility-first tools and from writing layouts directly with native CSS features. The comparison below shows where it fits among the most common alternatives.

ApproachCore ideaStrengthMain drawback
BootstrapPrebuilt components plus utilitiesFast, consistent results with little CSSRecognizable default look
Tailwind CSSUtility classes composed in markupFine-grained design controlVerbose class lists
Hand-written CSSCustom stylesheets with grid and FlexboxFull control and minimal weightMore time and expertise needed
CSS-in-JSStyles defined inside JavaScript componentsScoped styles tied to componentsRuntime cost and tooling complexity
Bootstrap and related styling approaches

Modern CSS has absorbed many reasons Bootstrap originally existed. Native CSS grid, container queries and custom properties now solve layout and theming problems that once required a framework. Bootstrap therefore delivers most value today through its tested, accessible components and shared conventions rather than through layout alone.

When to choose Bootstrap and common pitfalls

Bootstrap is the right choice when speed of delivery and consistency matter more than a distinctive visual identity. It suits internal tools, administration dashboards, prototypes and teams without a dedicated designer. It fits poorly when a brand requires a highly custom design, because fighting framework defaults can cost more than writing the CSS directly.

The decision table below maps typical project situations to a recommendation.

SituationRecommendationReason
Internal admin panelUse BootstrapReady components save weeks of work
Rapid prototypeUse Bootstrap from a CDNNo build setup is required
Branded marketing sitePrefer custom CSSDefault styling must be overridden heavily
Large design systemUse Bootstrap Sass selectivelyImport only the needed modules
Performance-critical pageAvoid the full bundleUnused CSS delays rendering
Choosing whether to use Bootstrap

The most frequent mistakes are shipping the entire framework when only the grid is used, overriding styles with high specificity or !important instead of changing Sass variables, and mixing major versions whose class names differ, such as ml-3 in Bootstrap 4 versus ms-3 in Bootstrap 5. Teams should also verify that customized components keep the accessibility attributes and focus states the framework provides.

The short version

Bootstrap is like a box of ready-made building parts for websites. Instead of designing every button, menu and page layout from nothing, a developer picks parts that already look good and work on phones, tablets and computers.

The parts follow one shared style, so pages look tidy and consistent with little effort. The catch is that many websites use the same box, so sites built with Bootstrap can look alike unless someone takes time to adjust the colors and shapes.

Where it makes a difference

A small logistics company needs an internal web application where dispatchers track around 400 daily shipments. The two developers assigned to it have strong backend skills but no designer on the team and a deadline of six weeks.

They install Bootstrap 5 through npm, override $primary with the company color, and import only the grid, forms, tables, buttons, navbar and modal modules. Shipment lists use striped responsive tables, filters sit in a collapsible sidebar that becomes an off-canvas panel below the large breakpoint, and editing happens in modal dialogs.

The result is a usable interface in about two weeks instead of the estimated five, with a compiled stylesheet of roughly 60 KB. Dispatchers use the same tool on desktop monitors and on tablets in the warehouse, and the developers spend the saved time on data validation and reporting rather than on layout bugs.