BootstrapBeginnerFree to read

Bootstrap components and the grid, with the CSS they replace

What Bootstrap gives you over hand-written CSS: the twelve-column grid, buttons, cards, alerts, forms, navbars and modals — each shown next to the CSS it saves you writing.

What you will be able to do
  • Lay out a responsive page with the Bootstrap grid and its breakpoint classes.
  • Assemble the common components — buttons, cards, alerts, forms, navbars, modals — from class names.
  • Say when a Bootstrap component is the right call and when custom CSS is less work.

What is CSS?

The foundation of web styling that makes everything look beautiful.

CSS Explained Simply

CSS (Cascading Style Sheets) is the language that describes how HTML elements should be displayed on screen. It controls everything visual about a webpage:

  • Colors - Text, backgrounds, borders
  • Layout - Positioning of elements
  • Typography - Fonts, sizes, spacing
  • Animations - Transitions and effects
  • Responsiveness - Adapting to different screen sizes
style.css
/* CSS Example */
.header {
  background: linear-gradient(to right,
  #4f46e5, #7c3aed);
  color: white;
  padding: 2rem;
  text-align: center;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.button {
  background-color: #3b82f6;
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.375rem;
  font-weight: 600;
  transition: all 0.2s;
}

.button:hover {
  background-color: #2563eb;
  transform: translateY(-1px);
}

The Challenge with Pure CSS

While CSS is powerful, building everything from scratch has challenges:

Time-Consuming

Writing custom CSS for every element takes significant time and effort.

Inconsistency

Maintaining visual consistency across a large project is difficult.

Responsiveness

Making designs work on all devices requires extensive media queries.

Complexity

Advanced layouts require deep CSS knowledge and testing.

Enter Bootstrap - CSS Made Simple

Bootstrap solves these challenges by providing a comprehensive set of pre-designed, responsive components and utilities that you can use with simple HTML classes.

Why Choose Bootstrap?

The smart way to build beautiful, responsive websites quickly.

Mobile-First Design

Works great on all screen sizes automatically with responsive breakpoints and components.

Saves Time

No need to design buttons, forms, layouts from scratch - just use pre-built components.

Consistent UI

Same polished look across all browsers with built-in normalization and reset styles.

Easy to Learn

Use simple class names like .btn, .text-center rather than writing custom CSS.

Large Community

Tons of themes, tutorials, and help available from a massive user base.

Responsive Grid

Powerful 12-column grid system for creating complex layouts with ease.

What is Bootstrap?

Bootstrap is a free, open-source CSS framework that provides ready-to-use design templates and components. Originally created by Twitter, it gives developers and designers a powerful toolkit for building responsive, mobile-first websites.

Instead of writing custom CSS for every element, Bootstrap provides pre-styled components that you can use by simply adding the right classes to your HTML. This means beautiful, consistent designs with minimal effort.

Without Bootstrap

Plain HTML, default browser styling

Plain HTML elements with default browser styling

Default unstyled content container

With Bootstrap

Pre-styled components

Pre-styled components with consistent design

Consistent styled container with padding and border

Key Features That Make Bootstrap Awesome

Everything you need to build modern websites efficiently.

Responsive Design

Bootstrap automatically adjusts your site layout to look great on phones, tablets, and desktops. The framework is built with a mobile-first approach, meaning it's designed to work on mobile devices first and then scale up components as necessary using responsive breakpoints.

Predefined CSS Classes

Want to add spacing or align text? Just use Bootstrap's utility classes — no need to write your own CSS. For example, use .text-center to center align text or .mt-3 to add margin top. Hundreds of such classes are available for all common styling needs.

Reusable Components

Use prebuilt UI elements like modals, dropdowns, navbars, and more with just a few lines of code. Bootstrap comes with dozens of components that are ready to use out of the box, saving you countless hours of development time. Each component is fully customizable and accessible.

Grid System

Bootstrap's 12-column grid lets you neatly arrange your layout — great for both simple and complex designs. The grid system is responsive and allows you to create layouts that work on any device size with minimal effort. Combine with flexbox utilities for even more layout control.

Grid System Comparison

Bootstrap Grid vs Custom CSS Grid implementations.

Bootstrap Grid

Basic Structure:

<div class="container">
  <div class="row">
    <div class="col-md-6">Left Column</div>
    <div class="col-md-6">Right Column</div>
  </div>
</div>
Renders as
Left Column
Right Column

Responsive Example:

<div class="row">
  <div class="col-12 col-sm-6 col-lg-3">Box 1</div>
  <div class="col-12 col-sm-6 col-lg-3">Box 2</div>
  <div class="col-12 col-sm-6 col-lg-3">Box 3</div>
  <div class="col-12 col-sm-6 col-lg-3">Box 4</div>
</div>
Renders as
Box 1
Box 2
Box 3
Box 4
Key Features:
  • 12-column fluid grid system
  • Five responsive tiers (xs, sm, md, lg, xl)
  • Built-in gutters (spacing between columns)
  • Auto-layout columns (equal width)
  • Column ordering and offsetting

Custom CSS Grid

Basic Structure:

<div class="custom-container">
  <div class="custom-row">
    <div class="custom-col">Left Column</div>
    <div class="custom-col">Right Column</div>
  </div>
</div>
Renders as
Left Column
Right Column

Responsive Example:

/* CSS Required */
.custom-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
}

@media (min-width: 576px) {
  .custom-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .custom-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
Renders as
Box 1
Box 2
Box 3
Box 4
Implementation Notes:
  • Requires manual CSS Grid or Flexbox implementation
  • Need to write all media queries yourself
  • Must handle gutters/spacing manually
  • Full control over column behavior
  • More code but potentially more flexible

Key Differences

When to Use Bootstrap Grid:

  • Quick prototyping and development
  • When you need consistent, responsive layouts
  • Team projects where consistency is important
  • When you want built-in responsive behaviors

When to Use Custom CSS Grid:

  • When you need unique, custom layouts
  • Projects where you want minimal dependencies
  • When you need maximum performance
  • For learning CSS Grid/Flexbox fundamentals

Bootstrap vs Custom CSS

Compare Bootstrap classes with equivalent custom CSS.

Buttons Comparison

Bootstrap Implementation

Using Bootstrap's button classes:

Bootstrap buttons
<!-- Bootstrap Button Classes -->
<button class="btn btn-primary">Primary</button>
<button class="btn btn-secondary">Secondary</button>
<button class="btn btn-success">Success</button>
<button class="btn btn-danger">Danger</button>
<button class="btn btn-warning">Warning</button>
<button class="btn btn-info">Info</button>

Custom CSS Implementation

Equivalent custom CSS:

Custom CSS buttons
/* Custom CSS Button Implementation */
.custom-btn {
  display: inline-block;
  font-weight: 400;
  text-align: center;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0.25rem;
  transition: all 0.15s ease-in-out;
  border: 1px solid transparent;
  color: white;
  margin: 0.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.custom-btn-primary {
  background-color: #0d6efd;
}
.custom-btn-primary:hover {
  background-color: #0b5ed7;
}

.custom-btn-secondary {
  background-color: #6c757d;
}
.custom-btn-secondary:hover {
  background-color: #5c636a;
}

.custom-btn-success {
  background-color: #198754;
}
.custom-btn-success:hover {
  background-color: #157347;
}

/* Plus similar styles for danger, warning, info buttons */

Cards Comparison

Bootstrap Implementation

Using Bootstrap's card classes:

Bootstrap card
Placeholder
Image Card

Card with an image on top.

<!-- Bootstrap Card Classes -->
<div class="card">
  <img src="..." class="card-img-top" alt="...">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <p class="card-text">Card content</p>
    <a href="#" class="btn btn-primary">Button</a>
  </div>
</div>

Custom CSS Implementation

Equivalent custom CSS:

Custom CSS card
Placeholder
Image Card

Card with an image on top.

/* Custom CSS equivalent */
.card-custom {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-img-top-custom {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.card-body-custom {
  padding: 1.5rem;
  background-color: white;
}

.card-title-custom {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

Alerts Comparison

Bootstrap Implementation

Using Bootstrap's alert classes:

Bootstrap alerts
This is a primary alert
This is a success alert
<!-- Bootstrap Alert Classes -->
<div class="alert alert-primary">Primary alert</div>
<div class="alert alert-success">Success alert</div>

Custom CSS Implementation

Equivalent custom CSS:

Custom CSS alerts
This is a primary alert
This is a success alert
/* Custom CSS equivalent */
.alert-custom {
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: 0.25rem;
}

.alert-primary-custom {
  color: #084298;
  background-color: #cfe2ff;
  border-color: #b6d4fe;
}

.alert-success-custom {
  color: #0f5132;
  background-color: #d1e7dd;
  border-color: #badbcc;
}

Form Comparison

Bootstrap (left) vs Custom CSS (right) implementation

Bootstrap Form

Bootstrap form
<!-- Bootstrap Form Code -->
<form>
  <div class="mb-3">
    <label class="form-label">Email</label>
    <input type="email" class="form-control">
  </div>
  <div class="mb-3">
    <label class="form-label">Password</label>
    <input type="password" class="form-control">
  </div>
  <div class="form-check mb-3">
    <input class="form-check-input" type="checkbox">
    <label class="form-check-label">Remember me</label>
  </div>
  <button type="submit" class="btn btn-primary">Sign in</button>
</form>

Custom CSS Form

Custom CSS form
/* Custom CSS Required */
.custom-form {
  max-width: 100%;
  font-family: sans-serif;
}

.custom-form-group {
  margin-bottom: 1rem;
}

.custom-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.custom-input {
  width: 100%;
  padding: 0.375rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
}

.custom-checkbox {
  margin: 1rem 0;
  display: flex;
  align-items: center;
}

.custom-button {
  width: 100%;
  padding: 0.5rem;
  background-color: #0d6efd;
  color: white;
  border: none;
  border-radius: 0.25rem;
}

Navbar Comparison

Bootstrap (left) vs Custom CSS (right) implementation

Bootstrap Navbar

Bootstrap navbar
<!-- Bootstrap Navbar -->
<nav class="navbar navbar-expand-lg bg-white">
  <div class="container-fluid">
    <a class="navbar-brand text-xl font-bold" href="#">Brand</a>
    <button class="navbar-toggler" type="button">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse">
      <div class="navbar-nav me-auto">
        <a class="nav-link" href="#">Home</a>
        <a class="nav-link" href="#">Features</a>
        <a class="nav-link" href="#">Pricing</a>
        <a class="nav-link" href="#">About</a>
      </div>
      <button class="btn btn-primary">Sign In</button>
    </div>
  </div>
</nav>

Custom CSS Navbar

Custom CSS navbar
/* Custom CSS Navbar */
.custom-navbar {
  background: white;
  padding: 1rem;
  width: 100%;
}

.custom-nav-container {
  display: flex;
  flex-direction: column;
}

.custom-brand {
  font-size: 1.25rem;
  font-weight: bold;
  color: #2563eb;
  margin-bottom: 1rem;
}

.custom-nav-links {
  display: none;
  gap: 1.5rem;
}

.custom-nav-link {
  color: #374151;
  text-decoration: none;
}

.custom-nav-link:hover {
  color: #2563eb;
}

.custom-nav-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.custom-nav-button {
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 0.375rem;
}

.custom-mobile-toggle {
  display: block;
}

@media (min-width: 768px) {
  .custom-nav-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .custom-brand {
    margin-bottom: 0;
  }

  .custom-nav-links {
    display: flex;
  }

  .custom-mobile-toggle {
    display: none;
  }

  .custom-nav-actions {
    margin-top: 0;
  }
}

Modal Comparison

Bootstrap (left) vs Custom CSS (right) implementation

Bootstrap Modal

Bootstrap modal
Bootstrap Modal

This is how a Bootstrap modal would appear.

<!-- Bootstrap Modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
  Launch modal
</button>

<div class="modal fade" id="exampleModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <div class="modal-body">
        <p>Modal content</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Custom CSS Modal

Custom CSS modal
Custom CSS Modal

This modal is styled with custom CSS.

/* Custom CSS Modal */
.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.custom-modal-content {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.custom-modal-close-btn {
  padding: 0.5rem 1rem;
  background: #e5e7eb;
  color: #374151;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
}

.custom-modal-save-btn {
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
}

/* Animation */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.custom-modal {
  animation: fadeIn 0.3s ease-out;
}

Bootstrap Themes

The style shortcut for your website - make it beautiful without writing CSS.

What's a Bootstrap Theme?

A Bootstrap theme is a pre-designed skin that customizes colors, typography, spacing, and component styles to give your website a unique and polished look.

Think of it like clothing for your HTML structure — Bootstrap gives you the body, and the theme gives it personality and style.

Modern Business Theme

Theme listing preview
Corporate Pro

Premium Bootstrap Theme — Popular

Professional theme perfect for corporate websites with clean design, multiple layout options, and extensive documentation.

$49

Final Thoughts: CSS vs Bootstrap Best Practices

Choosing the right approach for your projects.

Hybrid Approach: Best of Both Worlds

Many professional developers use a combination of Bootstrap and custom CSS:

  • Use Bootstrap for layout structure and base styling
  • Leverage Bootstrap's utility classes for common patterns
  • Override with custom CSS for unique branding elements
  • Extend Bootstrap with custom components when needed
Pro Tip:

Start with Bootstrap's source Sass files when possible. This lets you customize variables and only include the components you need, creating a tailored solution.

CoachingBootstrap

Build modern websites — HTML5, Tailwind CSS and React

Take the layout ideas here into a real front end, reviewed line by line as you write it.

Learn it here. Build it with us when you are ready.

Every lesson on this site is free and stays free. Bring the layout you are fighting and a mentor will work through it with you.

WhatsAppMessage us on WhatsApp
Visit12, Sri Vigneshwara Nagar, Amman Kovil
Saravanampatti, Coimbatore, TN, India — 641035

தெய்வத்தான் ஆகா தெனினும் முயற்சிதன்மெய்வருத்தக் கூலி தரும்.