Sub topic 9
Lay out the hero above the fold
This chapter assumes you know basic HTML and CSS, including CSS Grid, and have a headline, subheadline, call to action (CTA) and visual from earlier chapters. Here you place them so the offer is visible without scrolling.
What "above the fold" means on the web
The fold is the bottom edge of the viewport, the part of the page visible before any scrolling. There is no single fold. A phone, a laptop and a large monitor all show different amounts of the page. So you can't design for one pixel line. You design so that the offer and the CTA are visible on the smallest screen you support, and the rest of the hero improves on that.
The elements that must clear the fold are the headline, the subheadline and the primary CTA. The visual and any trust signals can sit partly below it.
Pick a layout pattern
Two patterns cover most heroes.
| Pattern | Best when | Risk |
|---|---|---|
| Text left, visual right | The product has a screenshot that explains it | The visual pushes the text down on small screens |
| Centered text, visual below | The offer is short and the visual is wide | The visual may fall below the fold |
For Ledgerly, the product screenshot shows what the offer does, so text left and visual right fits. On wide screens the reading order is text first, then image. That follows the order of importance you set in the visual hierarchy chapter.
Build the structure
Write the HTML in the order you want people and screen readers to meet the content: text, then image.
<section class="hero" aria-labelledby="hero-title">
<div class="hero__text">
<h1 id="hero-title">Send invoices in under a minute</h1>
<p class="hero__sub">Ledgerly helps freelancers create, send and track invoices, so you get paid sooner.</p>
<a class="hero__cta" href="/signup">Start free trial</a>
<p class="hero__note">No credit card required</p>
</div>
<img class="hero__image" src="/img/invoice-editor.webp" width="640" height="400" fetchpriority="high" alt="Ledgerly invoice editor showing a draft invoice with a Send button">
</section>Style it with a mobile-first grid
Start with one column. Grid places the text, then the image, in a single stack. A media query switches to two columns once there is room.
.hero {
display: grid;
gap: 2rem;
align-items: center;
padding: 3rem 1.25rem;
max-width: 72rem;
margin-inline: auto;
}
.hero h1 {
font-size: clamp(2rem, 5vw, 3.5rem);
line-height: 1.1;
margin: 0 0 1rem;
}
.hero__sub {
font-size: 1.125rem;
max-width: 40ch;
margin: 0 0 1.5rem;
}
.hero__cta {
display: inline-block;
padding: 0.875rem 1.5rem;
background: #0b5fff;
color: #fff;
border-radius: 0.5rem;
font-weight: 600;
text-decoration: none;
}
.hero__image {
width: 100%;
height: auto;
}
@media (min-width: 48rem) {
.hero {
grid-template-columns: 1fr 1fr;
}
}Three choices here protect the fold:
max-width: 40chkeeps the subheadline to a readable line length, so it doesn't stretch into a long, thin strip.clamp()lets the headline grow with the viewport but never become too small or too large.align-items: centerkeeps the text block aligned with the middle of the image, so a tall image doesn't leave the text stranded at the top.
How the content flows
Common errors
- Full-height heroes. Setting
min-height: 100vhcan push the CTA off the screen when browser toolbars take space. If you want a tall hero, don't depend on it to place the CTA. Keep the text block near the top. - Too much padding. Large top padding on a phone can use up a third of the screen before the headline appears. Reduce it for small widths.
- Image before text in the DOM. Using CSS
orderto move the image is fine visually, but screen readers and keyboard users follow the HTML order. Keep the HTML order and the visual order the same. - Decorative elements above the offer. Banners, announcement bars and large navigation menus all take fold space. Count them as part of the budget.
Exercise
On a 360-pixel-wide phone, the hero's CTA appears below the fold because the image comes first in a single column. Name two changes that bring the CTA back into view without removing the image.
Show answer
Put the text block before the image in the HTML so the stack starts with the offer and CTA, and reduce the hero's top padding. You could also cap the image height or move it further down the page on small screens, as long as the headline, subheadline and CTA stay on screen.