Hero banner backgrounds for online stores

The store hero is the biggest image most shoppers download. Here is how to size it, crop it for phones, keep text readable and swap it each season without breaking the layout.

9 min read
Empty dark display table with a wide blank backdrop panel and gift bags at one side
In short
  • Size the file from the slot: widest CSS width times 2. A hero capped at 1200 px needs a 2400 px export.
  • Give phones their own taller crop through the picture element, not a shrunken desktop banner.
  • Keep headline, price and button as HTML text inside a safe zone, with a scrim for contrast.
  • Budget about 300 KB on desktop and 150 KB on mobile, load the hero eagerly, skip auto-rotating carousels.
2400Pixel width for a 1200 px hero
4:5Mobile crop that fits a headline
300 KBDesktop hero budget

A store homepage banner has to work on a 390 px phone and a 2560 px monitor at the same time, and it is usually the largest image on the page. Teams that build shops end to end, such as YuSMP Group in its custom ecommerce website design projects, treat the hero as a layout component with fixed rules rather than a picture someone drops in. Below are those rules for the background layer.

What does a store hero background have to do?

A store hero background has three jobs: set the mood of the collection, keep the headline and button readable, and load fast enough that the first screen does not wait for it. Decoration comes last. A banner that looks good in the design file but hides the price or pushes the button below the fold is a failed banner.

Most store heroes fall into one of four patterns:

  • Full-bleed photo with text on top. A lifestyle or product shot fills the width, and the copy sits over a quiet part of the image.
  • Texture or gradient with a product cut-out. The background is a surface, such as paper, linen, marble or a soft mesh, and the product sits on it as a separate image.
  • Split layout. Text on a plain or textured panel on one side, photo on the other. The background only has to carry half the width.
  • Carousel. Several of the above, rotating. Covered separately below, because it changes the performance math.

The texture-plus-cut-out pattern is the easiest to keep consistent across a catalog. The surface stays the same for weeks, and only the product layer changes. For the photography side of that setup, see product photo backgrounds.

What size should an ecommerce hero banner be?

Size the banner from the slot, not from a number you read somewhere. Measure the widest CSS width the hero renders at, multiply by 2 for high-density screens, and export at that width. A hero capped at 1200 CSS px needs a 2400 px file. A hero that runs edge to edge on a 1920 px monitor needs more, but most stores cap the content width, and the background can stop at the same cap or fade into a solid color beyond it.

Store themes usually crop desktop heroes wide, somewhere between 3:1 and 16:9. Phones need the opposite: a taller crop, because a 3:1 banner on a 390 px screen is only 130 px high and the headline will not fit.

SlotAspect ratioExport widthTarget weight
Desktop full-width hero3:1 to 16:92400 px150 to 300 KB
Tablet hero16:9 or 4:31536 px100 to 200 KB
Mobile hero4:5 or 1:11170 px60 to 150 KB
Collection banner4:1 to 6:12400 px80 to 200 KB

The weights assume AVIF or WebP at medium quality. Treat them as a budget, not a promise: a busy photo needs more bytes than a soft gradient at the same pixel size.

Textures behave better than photos here. Every file on this site is 1600×1200. A 3:1 crop of it gives 1600×533 px, which is enough for a capped desktop hero at 1x. On a 2x screen it is upscaled, and soft surfaces like soft gradient mesh backgrounds or kraft paper hide that well. Sharp product photos do not. For the pixel math behind this, see background resolution for web and print.

How do you give mobile its own crop?

Use the <picture> element with a media condition. This is called art direction: the phone gets a different crop of the image, not just a smaller copy of the desktop file. MDN documents the pattern in its reference for the element.

<picture class="hero-bg">
  <source media="(max-width: 640px)"
          type="image/avif"
          srcset="/img/hero-winter-m.avif 1170w">
  <source media="(max-width: 640px)"
          srcset="/img/hero-winter-m.webp 1170w">
  <source type="image/avif"
          srcset="/img/hero-winter-1200.avif 1200w,
                  /img/hero-winter-2400.avif 2400w">
  <img src="/img/hero-winter-2400.webp"
       srcset="/img/hero-winter-1200.webp 1200w,
               /img/hero-winter-2400.webp 2400w"
       sizes="(max-width: 1200px) 100vw, 1200px"
       width="2400" height="800"
       alt="" fetchpriority="high">
</picture>

Three details matter in that snippet:

  1. Order of sources. The browser takes the first <source> that matches. Put the mobile conditions first, AVIF before WebP inside each group.
  2. Empty alt. If the image is pure background and the headline is real HTML text, use alt="". If the banner shows a specific product the shopper needs to know about, describe it.
  3. Width and height. Set them to the desktop ratio and override the mobile ratio in CSS. That keeps the layout from jumping while the file loads.

Then position the image like a background:

.hero { position: relative; aspect-ratio: 3 / 1; }
.hero-bg img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 70% 50%;
}
@media (max-width: 640px) {
  .hero { aspect-ratio: 4 / 5; }
}

object-position keeps the focal point, often the product, in frame when the slot is narrower than the file. Set it per banner if the product moves from campaign to campaign.

Soft gradient mesh backgrounds, original variant

Where should text sit on the background?

Text should sit on the calmest part of the image, inside a safe zone you define before anyone shoots or picks the background. A workable starting point: keep headline and button inside the left 45 percent of the desktop crop and the bottom 40 percent of the mobile crop, and keep the product out of both zones.

Write the zones into the brief for every new banner. It saves a redesign when a photographer delivers a shot with the subject dead center.

Contrast is the hard limit. Under WCAG, body text needs at least 4.5:1 against what is behind it, and large text needs 3:1. Over an image, what is behind the text changes from pixel to pixel, so test the busiest spot under the letters, not the average. A scrim fixes most banners:

.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg,
    rgb(0 0 0 / .65) 0%,
    rgb(0 0 0 / .35) 40%,
    rgb(0 0 0 / 0) 60%);
}
.hero-copy { position: relative; z-index: 1; }

On mobile, turn the gradient to run bottom to top, matching the mobile safe zone. The full method, including what counts as large text and why text-shadow alone is not enough, is in readable text on background images.

One more rule: never bake the headline or the price into the image file. Text in a JPG cannot be translated, read by screen readers, indexed or updated for a sale without a new export.

How heavy can the banner be?

Keep the hero file at or under 300 KB on desktop and 150 KB on mobile, because on most store homepages it is the Largest Contentful Paint element. web.dev sets a good LCP at 2.5 seconds or less, and a 1 MB banner on a mid-range phone makes that hard to reach.

The short version of the performance rules:

  • Use an <img> in the HTML for the hero, not a CSS background-image. The browser finds an <img> while parsing; a CSS background waits for the stylesheet.
  • Add fetchpriority="high" to the hero image and never loading="lazy".
  • Serve AVIF with a WebP fallback. Both are supported in current Chrome, Edge, Firefox and Safari.
  • Do not load the desktop file on a phone. The <picture> setup above already handles that.

Each of these, with measurements and the preload variant for CSS backgrounds, is covered in fast background images.

Usually not for the first screen. A carousel loads several large images where one would do, and every extra slide is another crop and another contrast check. If the business insists on one, limit the damage:

  • Load only the first slide eagerly. Give the rest loading="lazy" and the same dimensions, so nothing shifts.
  • Keep all slides on the same background system: same safe zone, same scrim, same ratio. Otherwise each slide needs its own contrast check.
  • Do not auto-rotate. If you must, add a visible pause button: WCAG success criterion 2.2.2 requires a way to pause content that moves automatically for more than five seconds.

A single strong banner with a link to the campaign page tends to be easier to maintain and easier to measure.

How should collection and category banners differ?

Collection banners are shorter strips at the top of a category page, often 4:1 to 6:1. They are a good place for a CSS background, because they are rarely the LCP element: the product grid below usually is.

.collection-head {
  min-height: 220px;
  background:
    linear-gradient(rgb(0 0 0 / .45), rgb(0 0 0 / .45)),
    image-set(
      url("/img/kraft-strip.avif") type("image/avif"),
      url("/img/kraft-strip.webp") type("image/webp")
    ) center / cover;
}

Here a textured surface works better than a photo. A strip that is 6 times wider than it is tall crops any photo badly on some screen width, while a texture has no subject to lose. One texture per department, such as kraft paper for a handmade range or slate for a premium one, gives each section a recognizable look without a new shoot.

If the strip is very wide and the texture is seamless, you can also tile a small file instead of stretching a large one. That approach is covered in seamless tileable textures.

How do you swap seasonal banners without layout shift?

Fix the slot once and let the content team swap files inside it. Stores replace hero images several times a year, for a sale, a holiday or a new collection, and the layout should not care:

  • Lock the ratio in CSS with aspect-ratio, per breakpoint. A new file with a slightly different size then gets cropped, not reflowed.
  • Keep the safe zones in a template file. A layered design file with the text zone marked out is the cheapest quality gate you can give a designer.
  • Name files by campaign and crop, such as hero-winter-2400.avif and hero-winter-m.avif. A new name also avoids stale CDN caches, which a reused name like hero.jpg does not.
  • Store the focal point with the banner. If your CMS has a field for object-position, the product stays in frame on every crop without code changes.

Pre-launch checklist for a store hero banner

  1. Desktop, tablet and mobile crops exported at the widths in the table, AVIF and WebP.
  2. Mobile crop set through <picture> with media, not just downscaled.
  3. Width and height attributes present; aspect-ratio set per breakpoint.
  4. Hero image has fetchpriority="high" and no lazy loading.
  5. Headline, price and button are HTML text inside the safe zone.
  6. Contrast checked at the busiest point under the text: 4.5:1 for body, 3:1 for large text.
  7. Product stays in frame at 390 px, 768 px, 1280 px and 1920 px viewport widths.
  8. If there is a carousel: first slide eager, others lazy, pause control visible.

Questions about store hero banners

What size should an ecommerce hero banner be?

Measure the widest CSS width the hero renders at and export at twice that width. For a hero capped at 1200 px that is a 2400 px file, usually at a 3:1 to 16:9 ratio on desktop. Phones need a separate taller crop, such as 4:5 at about 1170 px wide.

Should the hero banner be a CSS background or an img element?

Use an img element, ideally inside picture. The browser discovers it while parsing the HTML and can load it early, which helps Largest Contentful Paint. CSS backgrounds suit shorter collection strips that are not the largest element on the page.

How do I stop the product being cropped out on mobile?

Export a dedicated mobile crop and serve it with a source element that has a media condition. Then set object-position on the image so the focal point stays in frame when the slot is narrower than the file.

Can I put the sale text into the banner image?

It is better not to. Text inside an image cannot be read by screen readers, translated, indexed or changed without a new export. Keep the headline, price and button as HTML on top of the background.

Are free textures suitable for store banners?

Yes, as a background surface behind products and copy. Soft textures and gradients also survive crops and upscaling better than detailed photos. Check the license of each file; the backgrounds on this site are free for commercial use without attribution.

Keep reading

Built for the web.
Free to download.