#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Bootstrap Fundamentals

Bootstrap CSS

Bootstrap CSS is the stylesheet part of Bootstrap 5: a ready-made set of base styles and utility classes that you apply by adding class names to your HTML. Instead of writing your own CSS for spacing, colours, borders or alignment, you add classes like mt-3 or text-center and get consistent, responsive results across the page.

Adding the stylesheet to a page

The quickest way is to link the compiled file from a CDN in the <head>, along with the viewport meta tag that Bootstrap's responsive features rely on. In larger projects you can install it with npm install bootstrap and import it through your build tool.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  <title>Bootstrap page</title>
</head>
<body>
  <div class="container py-4">
    <h2 class="text-primary mb-3">Welcome</h2>
    <p class="lead">Styled with Bootstrap classes only.</p>
    <div class="p-3 bg-light border rounded-3 shadow-sm">
      A padded, bordered box with rounded corners.
    </div>
  </div>
</body>
</html>

Reboot: the base layer

When the stylesheet loads, it first applies Reboot, a set of element-level rules. Reboot sets box-sizing: border-box on every element, removes the default top margin from headings and paragraphs, uses a system font stack and gives the body a sensible line height. That is why a page looks slightly different the moment you add Bootstrap, even before you use a single class.

Reading utility class names

Most utilities follow a short pattern of property, side and size. Learning the pattern once lets you guess the rest:

ClassWhat it does
m-0, mt-3, mx-autoMargin on all sides, top, or left and right.
p-2, px-4, py-5Padding, on the same side scheme.
text-center, text-md-startText alignment, optionally from a breakpoint up.
bg-dark, text-white, text-body-secondaryBackground and text colours from the theme.
d-none, d-md-block, d-flexDisplay values, including responsive show and hide.
border, rounded, shadowBorders, corner radius and box shadows.

Spacing sizes run from 0 to 5, each a fixed step based on the root font size. Inserting a breakpoint, as in mt-md-5, applies the rule only from that screen width upward, matching Bootstrap's mobile-first approach.

CSS variables and theming

Bootstrap 5 exposes many values as CSS custom properties, such as --bs-primary and --bs-body-font-size. You can override some of them in your own stylesheet for small changes. For deeper theme changes, like a new primary colour that updates every button and link state, the recommended route is compiling Bootstrap from its Sass source with your own variables. Version 5.3 also supports a dark colour mode through data-bs-theme="dark" on an element.

Common mistake: fighting the cascade

Beginners often write a custom rule like .btn { padding: 4px; } and find it ignored. Usually the custom stylesheet is linked before Bootstrap, so Bootstrap's rule wins. Link your own CSS after Bootstrap. Avoid sprinkling !important to force changes; note that utility classes already use !important on purpose, so a utility such as p-0 will beat your normal rules. If you keep overriding the same thing, a utility or a theme variable is usually the better tool.

In short

Bootstrap CSS gives you Reboot defaults plus a predictable utility vocabulary. Link it with the viewport tag, learn the property-side-size naming, add breakpoints for responsive tweaks, and load your own styles afterwards so small customisations apply cleanly.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course