Bootstrap Jumbotron
Learn how to create a large banner section to highlight important content, announcements, and calls to action.
What is a Jumbotron?
A jumbotron is a large section used to highlight important content on a website. It can contain a heading, description, and action buttons.
In Bootstrap 5, the old .jumbotron component
is no longer available. We can create a similar section
using spacing, background, and typography utility classes.
1. Basic Jumbotron
Use .p-5 for spacing,
.bg-light for the background, and
.rounded for rounded corners.
Program Code:
<div class="p-5 bg-light rounded">
<h1 class="display-4">
Welcome to Our Website!
</h1>
<p class="lead">
Learn new skills with our training programs.
</p>
<button class="btn btn-primary">
Learn More
</button>
</div>
Output:
Welcome to Our Website!
Learn new skills with our training programs.
2. Jumbotron with Background Color
Use Bootstrap background classes to highlight the banner. Choose a suitable text color for readability.
Program Code:
<div class="p-5 bg-primary text-white rounded">
<h1 class="display-5 fw-bold">
Start Learning Today
</h1>
<p class="lead">
Build your skills with practical training.
</p>
<button class="btn btn-light">
Explore Courses
</button>
</div>
Output:
Start Learning Today
Build your skills with practical training.
bg-primary creates a blue background,
while text-white makes the text white.
3. Jumbotron with Call to Action
A call to action encourages users to perform a specific activity, such as registering or exploring courses.
Program Code:
<div class="p-5 bg-light border rounded">
<h2 class="fw-bold">
Join Our Training Program
</h2>
<p class="lead">
Learn through practical examples and live projects.
</p>
<a href="#" class="btn btn-success">
Enroll Now
</a>
</div>
Output:
href="#" with
the actual registration URL when available.
4. Jumbotron with Border
Use .border and .rounded
to create a banner with a visible border.
Program Code:
<div class="p-5 border rounded">
<h2 class="fw-bold">
Learn Bootstrap
</h2>
<p>
Create responsive websites with Bootstrap utilities.
</p>
</div>
Output:
Learn Bootstrap
Create responsive websites with Bootstrap utilities.
5. Jumbotron with Centered Content
Use .text-center to align the heading,
description, and button in the center.
Program Code:
<div class="p-5 bg-light rounded text-center">
<h1 class="fw-bold">
Welcome to CIIT
</h1>
<p class="lead">
Learn programming through practical training.
</p>
<button class="btn btn-primary">
View Courses
</button>
</div>
Output:
Welcome to CIIT
Learn programming through practical training.
.text-center class centers the
text and button inside the banner.
6. Jumbotron with Multiple Buttons
You can add more than one button to provide different actions to the user.
Program Code:
<div class="p-5 bg-light rounded">
<h2 class="fw-bold">
Upgrade Your Skills
</h2>
<p>
Explore our programming courses.
</p>
<a href="#" class="btn btn-primary me-2">
Explore Courses
</a>
<a href="#" class="btn btn-outline-primary">
Contact Us
</a>
</div>
Output:
Important Bootstrap Classes
| Class | Purpose |
|---|---|
.p-5 |
Adds padding inside the banner. |
.bg-light |
Applies a light background. |
.bg-primary |
Applies the primary background color. |
.text-white |
Changes the text color to white. |
.display-4 |
Creates a large display heading. |
.lead |
Highlights introductory paragraph text. |
.rounded |
Adds rounded corners. |
.text-center |
Centers inline content and text. |
.btn |
Creates a styled button or link. |
Common Mistakes
-
Using
.jumbotronas if it were a built-in Bootstrap 5 component. - Forgetting to add padding to the banner.
- Using text and background colors with poor contrast.
- Adding too much content to the banner.
- Forgetting to replace placeholder links with actual destination URLs.
Summary
A jumbotron-style section highlights important content using a large heading, description, and optional buttons.
-
Bootstrap 5 does not include the old
.jumbotroncomponent. - Use spacing, background, and typography utility classes to create a similar banner.
-
Use
.p-5to add spacing. - Use background and text classes to style the banner.
- Use buttons to provide clear actions to visitors.