TExcelTAD
Home › Bootstrap › BS5 Jumbotron / Hero

Bootstrap 5 Jumbotron / Hero

A jumbotron (or hero section) is the big, attention-grabbing box at the top of a landing page: a large heading, a short pitch and a call-to-action button. Bootstrap 4 had a .jumbotron class; Bootstrap 5 removed it, because the same result is easy to build with utility classes — and that gives you more control.

Building a hero from utilities

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
  <div class="p-4 p-md-5 bg-body-tertiary rounded-3">
    <h1 class="display-6 fw-bold">Learn to code, one page at a time</h1>
    <p class="lead">Short lessons, live examples and quizzes that run right in your browser.</p>
    <button class="btn btn-primary btn-lg">Start learning</button>
  </div>
</body>
</html>

The ingredients:

Class Job in the hero
p-4 p-md-5 Generous padding, more on wider screens
bg-body-tertiary Light grey background that adapts to dark mode
rounded-3 Large rounded corners
display-* / fw-bold Big, bold headline
lead Larger intro sentence
btn-lg Larger call-to-action button

A full-width, centred hero

For a hero that spans the whole page, use a full-width section with a .container inside so the text stays aligned with the rest of the page. Centre everything with text-center and limit the paragraph width with columns.

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <style>
    .hero { background: linear-gradient(135deg, #7952b3, #0dcaf0); }
  </style>
</head>
<body>
  <section class="hero text-white text-center py-5">
    <div class="container">
      <div class="fs-1">🚀</div>
      <h1 class="fw-bold">Launch faster</h1>
      <div class="row justify-content-center">
        <p class="lead col-lg-8">Prototype responsive pages in minutes with ready-made components.</p>
      </div>
      <div class="d-flex gap-2 justify-content-center flex-wrap">
        <a href="#" class="btn btn-light btn-lg px-4">Get started</a>
        <a href="#" class="btn btn-outline-light btn-lg px-4">Docs</a>
      </div>
    </div>
  </section>
</body>
</html>

Note: The preview frame is about 280px tall, so a big hero may need scrolling. Drag the frame's bottom-right corner down to see it all at once.

Hero with text and a picture

A two-column hero puts the pitch on one side and an illustration on the other. Below the lg breakpoint the columns stack; flex-lg-row-reverse places the picture on the right on wide screens while keeping it first in the HTML (so it appears on top on phones).

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
  <div class="container py-4">
    <div class="row flex-lg-row-reverse align-items-center g-4">
      <div class="col-10 col-sm-8 col-lg-5 mx-auto">
        <div class="ratio ratio-16x9 rounded-4 shadow"
             style="background: radial-gradient(circle at 30% 30%, #ffc107, #fd7e14 60%, #dc3545);">
          <div class="d-flex align-items-center justify-content-center display-3">🎨</div>
        </div>
      </div>
      <div class="col-lg-7">
        <h2 class="fw-bold lh-1 mb-3">Design that adapts</h2>
        <p class="text-body-secondary">Stacked on narrow screens, side by side on large ones.</p>
        <button class="btn btn-primary">Try it</button>
      </div>
    </div>
  </div>
</body>
</html>

The .ratio .ratio-16x9 wrapper keeps the illustration at a fixed aspect ratio whatever its width.

Common patterns

Want Classes
Full-viewport hero min-vh-100 d-flex align-items-center on the section
Dark hero text-bg-dark (or bg-dark text-white)
Centred narrow text col-lg-8 mx-auto or row justify-content-center
Buttons stacked on phones, inline on desktop d-grid gap-2 d-sm-flex

Tip: Keep the hero focused: one message, one primary action. A secondary outline button is fine; five buttons is a menu, not a hero.

Test yourself

What happened to the .jumbotron class in Bootstrap 5?

  1. It was renamed .hero
  2. It was removed; build heroes with utilities
  3. It now needs JavaScript
  4. It only works in dark mode

Which class is good for the large intro sentence in a hero?

  1. .lead
  2. .small
  3. .h6
  4. .text-truncate

What does p-4 p-md-5 mean?

  1. Padding 4 on mobile, 5 from the md breakpoint up
  2. Padding 4 and margin 5
  3. Padding between 4 and 5
  4. Padding 5 on mobile, 4 on desktop