Skip to content

Hero with Background Overlay

Full-width Bootstrap 5 hero section with a cover background image, dark gradient overlay, fluid headline, two call-to-action buttons and a stats row.

Also known as: hero banner with background image, full width hero section, hero image overlay, landing page header image

Hero with Background Overlay live demo

Open in new tab

Bootstrap 5 code (HTML, CSS)

A full-width Bootstrap 5 hero section with a background image, a dark gradient overlay, a pill eyebrow, a large headline, two call-to-action buttons and a row of stats. It suits travel sites, agencies, event pages and any landing page that opens with a strong photo.

How it works

The root section.ho-hero is a flex container with align-items-center and a min-height taken from --ho-min-height, so the content is vertically centered. The background is a real img.ho-hero__bg (a placehold.co placeholder) stretched with position: absolute, inset: 0 and object-fit: cover. Using an image element instead of a CSS background-image lets the browser load it early (fetchpriority="high") and lets you use srcset for responsive images.

On top sits .ho-hero__overlay, an absolutely positioned layer with two stacked gradients: one darkens the bottom edge, the other runs from almost opaque on the left (--ho-overlay-from) to lighter on the right (--ho-overlay-to). The text sits on the darkest part, so contrast stays high even with a bright photo. isolation: isolate on the root keeps the negative z-index of the image and overlay inside the section.

The content uses a Bootstrap container and a col-lg-8 col-xl-7 column. The headline .ho-hero__title scales fluidly with clamp(), and text-wrap: balance evens out its lines. The buttons stack on phones (flex-column) and sit side by side from the sm breakpoint. The .ho-hero__stats list wraps onto several lines on narrow screens. No JavaScript is required.

Customization

  • src of .ho-hero__bg: replace the placeholder with your own photo; adjust object-position in .ho-hero__bg to keep the subject visible on phones.
  • --ho-overlay-from and --ho-overlay-to in .ho-hero: make the overlay darker, lighter or tinted (for example a navy or brand color).
  • --ho-accent and --ho-accent-text in .ho-hero: change the color of the primary button.
  • --ho-min-height in .ho-hero: use 100vh for a full-screen hero or 60vh for a shorter banner.
  • col-lg-8 col-xl-7 on the content column: widen it, or add mx-auto text-center for a centered layout.
  • Remove .ho-hero__stats if you only need a headline and buttons.
  • font-size: clamp(2.25rem, 6vw, 4.25rem) in .ho-hero__title: change the minimum and maximum headline size.

Use cases

  • Travel sites: a full-width photo hero with a dark gradient keeps the headline readable on any image
  • Agency websites: two call-to-action buttons and a stats row open the page with a strong first impression
  • Event pages: the fluid headline scales smoothly from phones to large screens
  • Landing pages: switch to a full-screen or shorter banner by changing a single height variable

Accessibility

The background image has an empty alt because it is decorative, and the overlay has aria-hidden="true". The section is labelled by its h1 through aria-labelledby. All icons are hidden from screen readers. Text is light on a gradient that stays near 90% black behind the copy, giving strong contrast. Buttons have a clear :focus-visible outline in white, and the hover lift and transitions are disabled with prefers-reduced-motion: reduce.

Usage notes

Requires Bootstrap 5 (added automatically) and Bootstrap Icons. If the hero is not the first heading on your page, change the h1 to an h2. Replace the href="#" values with your own links.

Hero with Background Overlay at a glance

Framework
Bootstrap 5
Code
HTML, CSS
JavaScript
Only Bootstrap 5's own script
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Hero Sections
License
Free for personal and commercial use

Questions about this template

Can I use the Hero with Background Overlay code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear and add the CSS to your stylesheet. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. Only Bootstrap 5's own JavaScript is used, and the download already includes it.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Hero with Background Overlay – free Bootstrap 5 hero section template
Hero with Background Overlay · free Bootstrap 5 hero section template

More Hero Sections

Split Hero with Diagonal Photo Clip – free Pure CSS hero section template

Split Hero with Diagonal Photo Clip

Pure CSS split hero with headline, buttons and stats beside a full-height photo cut on a diagonal with clip-path, plus an accent stripe and rating badge.

Hero with Rotating Words – free Pure CSS hero section template

Hero with Rotating Words

Dark hero section whose headline cycles through words with a slide-and-fade animation, a pause button and decorative stat cards.

Split Hero with App Screenshot – free Tailwind CSS hero section template

Split Hero with App Screenshot

Dark Tailwind CSS split hero with gradient headline, two CTA buttons and an animated mock app dashboard built entirely from divs.

Hero with Background Video Overlay – free Bootstrap 6 hero section template

Hero with Background Video Overlay

Full-width Bootstrap 6 hero with a muted background video or slow-zoom poster photo, dark gradient overlay, headline, two buttons, stats and a pause control.

Dark Gradient Hero – free Bootstrap 6 hero section template

Dark Gradient Hero

Dark Bootstrap 6 hero with a blurred gradient mesh, gradient headline, glowing CTA, copyable install command, decorative orb with stats and a row of trust logos.

Split Hero with Stats – free Bootstrap 6 hero section template

Split Hero with Stats

Bootstrap 6 split hero with a highlighted headline, CTAs and avatar social proof beside a bento grid of key stats with a 12-month / all-time toggle.