Quick Answers
How tall should a mobile sticky header be?
Between 48 and 56 pixels once pinned. That fits a 44 pixel tap target and one action, and it lands under 10 per cent of a typical phone viewport. Above roughly 117 pixels on a 780 pixel visible screen, you are over the 15 per cent ceiling.
Why does my sticky header cover the content underneath it?
The scroll offset is missing or wrong. Add scroll-padding-top on the scroll container and scroll-margin-top on anchor targets, both equal to the pinned header height. If the header shrinks, update that value when it changes, or the offset is stale.
Should the header hide when the visitor scrolls down?
On reading pages, yes. The visitor is going down to consume content and up to navigate, so hiding on the way down gives the screen back. On checkout, forms and app-like screens, keep it visible, because navigation is the task there.
How do I measure the share of the screen my header takes?
Divide the rendered header height by the visible viewport height, not by 100vh. A three line console snippet at the end of this article prints both numbers and the percentage, so you can measure the real page rather than the design file.
The Number Nobody Measures
A header is approved on a desktop monitor at 1440 pixels wide, where it looks modest. The same header then ships to a 390 pixel phone, which has a fraction of the vertical space.
The number that matters is the mobile sticky header height as a share of what the visitor can see. That is a division sum, and almost nobody has run it.
The 10-15% Rule
Measure the pinned height of the header, the height it holds after the page scrolls, and divide it by the visible viewport height.
Work to a budget of 10 per cent, with 15 per cent as a hard ceiling. Not because a study said so, but because of what the percentage costs in reading.
| Pinned header | Share of a 780px visible viewport | Verdict |
| 48px | 6.2% | Fine. Two lines of body text or less |
| 56px | 7.2% | Fine. The common choice |
| 78px | 10.0% | At the target |
| 117px | 15.0% | At the ceiling |
| 156px | 20.0% | A fifth of the screen, gone for good |
| 195px | 25.0% | A quarter. The page feels like a frame |
The percentages are a simple division against a 780 pixel visible height. Substitute your own measurement and the thresholds move with it.
Why 15 per cent rather than 20? Body text is measured in lines. At 16 pixels with 1.5 line height, one line is about 24 pixels, so a 117 pixel header is roughly five lines. Past that, the header stops being a navigation aid and becomes a frame around the content.
A second limit hides inside the percentage. On a small phone, 15 per cent is fewer absolute pixels, so a header can pass the percentage check and still fail the tap target check. Apply both: an optimal mobile header size is roughly 48 to 56 pixels, which also clears a 44 by 44 point target.
Measure It in Three Lines
Open the page on a real phone, or in a device emulator, and paste this into the console.
const header = document.querySelector(‘header’);
const h = header.getBoundingClientRect().height;
const vh = window.visualViewport ? window.visualViewport.height : innerHeight;
console.log(`header ${h}px / viewport ${vh}px = ${(h / vh * 100).toFixed(1)}%`);
visualViewport.height is the part most people miss. It reports what the visitor can see after the toolbar and on-screen keyboard take their space, which is smaller than innerHeight. Measuring against a viewport that includes toolbar space flatters the header.
Scroll the page first, then run it. A header that shrinks on scroll has two heights, and the pinned one is the one that matters.
When the Header Covers Content
A sticky header overlapping content mobile report almost always has one of four causes, and they are worth separating before anyone edits padding.
| Symptom | Cause | Fix |
| The first heading is hidden on load | Fixed header removed from flow, no compensating space | Use position: sticky, or add top padding equal to the height |
| Anchor links land under the header | No scroll offset on the target | scroll-padding-top on the container, scroll-margin-top on targets |
| Jump links worked, then stopped a week later | The header shrinks, but the offset is still the old height | Drive the offset from a CSS variable updated on resize |
| Keyboard focus disappears behind the bar | Focused element scrolled under a pinned header | The same offset fix, plus a focus check |
One variable, set in one place, covers three of those.
:root {
--header-h: 56px;
}
html {
scroll-padding-top: var(--header-h);
}
:target,
h2[id],
h3[id] {
scroll-margin-top: var(--header-h);
}
.site-header {
position: sticky;
top: 0;
block-size: var(--header-h);
z-index: 100;
background: #fff;
padding-inline: max(1rem, env(safe-area-inset-left));
}
Update the variable from JavaScript when the header changes size, and every anchor and scroll offset follows. That is the difference between a fix and a recurring bug.
Prefer position: sticky over fixed: a sticky element stays in the document flow and needs no compensating padding. Check for an ancestor with overflow: hidden, which silently turns sticky behaviour off.
The Three Header Models
The decision is not about taste. It depends on what the visitor is doing on that page.
| Model | Use when | Height budget | What it costs | Fails when |
| Fixed sticky | Navigation is the task (checkout, account, app-like screens) | 48 to 56px on mobile | Permanent share of the viewport | Reading pages, where it takes space from text |
| Smart scroll | Long reading pages, content sites, documentation | 48 to 56px pinned, hidden while scrolling down | A small amount of JavaScript, and states to test | Short pages, where it flickers near the top |
| Static | Marketing pages, hero-led layouts, anything with one screen of content | No budget, it scrolls away | One scroll back for navigation | Very long pages with no way back to navigation |
A useful default for a responsive sticky nav: static for marketing pages, fixed for app-like screens, smart for anything a visitor reads for more than a screen.
Hide on Scroll Down, Show on Scroll Up
The pattern people search for as hide sticky header on scroll down is simple in principle: hide on the way down, reveal as soon as the visitor scrolls up. Most implementations attach a raw scroll listener, which is the part worth doing differently.
(() => {
const header = document.querySelector('.site-header');
let last = window.scrollY;
let queued = false;
const update = () => {
const y = window.scrollY;
const delta = y - last;
// Ignore jitter at the top and tiny movements
if (y > 120 && Math.abs(delta) > 6) {
header.classList.toggle('is-hidden', delta > 0);
last = y;
}
queued = false;
};
window.addEventListener('keydown', (e) => {
if (e.key === 'Tab') header.classList.remove('is-hidden');
});
window.addEventListener('scroll', () => {
if (!queued) {
queued = true;
requestAnimationFrame(update);
}
}, { passive: true });
})();
.site-header {
transition: transform 180ms ease;
}
.site-header.is-hidden {
transform: translateY(-100%);
}
@media (prefers-reduced-motion: reduce) {
.site-header {
transition: none;
}
}
The listener is passive, so it cannot block scrolling. Work is batched into requestAnimationFrame, so a fast scroll does not run the handler dozens of times per frame. The threshold stops the header twitching on a small nudge.
The keydown listener is the part most implementations leave out. A keyboard user tabbing into a link does not scroll, so the header stays hidden and the focused element can sit under it.
The Cases This Pattern Breaks
Four situations need a deliberate answer rather than a default.
- Focus visibility. WCAG 2.2 asks that a focused element is not entirely hidden by author content, and a pinned header is that risk.
- Reduced motion. The media query above removes the animation for visitors who asked for it.
- Short pages. On a one screen page the header just flashes. Gate it behind a minimum scroll distance.
- The browser toolbar. Visible height changes as the toolbar hides mid-scroll, so recalculate on resize and orientation change.
These are the mobile ui header best practices that survive a real device: measure the visible viewport, budget the space, and test the states nobody clicks.
A Ten Minute Test Pass
| Test | Expected |
| Load the page on a phone, unscrolled | Header visible, first heading not hidden |
| Tap every anchor link | Section heading lands below the header |
| Scroll down, then up | Hides going down, returns going up, no flicker |
| Tab through with the header hidden | Header returns, focus stays visible |
| Rotate to landscape | Header fits, no overlap, no missing padding |
| Zoom to 200 per cent | Content readable, header does not swallow the page |
If Your Header Is Costing You Mobile Readers
A header that takes up a quarter of the screen is a decision nobody consciously made, and it shows up as shorter sessions rather than a complaint. Our UI/UX design team measures navigation against real viewports and tests the states that only appear on a device. When the fix belongs in the theme or the build, our website redesign service carries it through properly.
Frequently Asked Questions
Is 100vh the right thing to measure against?
No. On a phone, 100vh includes space the toolbar may occupy, so it overstates what the visitor sees. Use visualViewport.height in JavaScript, or dvh and svh in CSS, which account for the toolbar.
Does position fixed or position sticky change the space taken?
Both take the same visual space when pinned. The difference is flow: fixed leaves the document, so the content underneath needs padding, while sticky keeps its place. Sticky is usually the smaller change.
Will hiding the header hurt navigation?
Not if the reveal is reliable. The risk is a header that fails to return, which is why the scroll-up threshold and the keyboard guard matter more than the hide.
What about a bottom navigation bar instead?
On app-like products a bottom bar often wins, because it sits in the thumb zone. On content pages it competes with the toolbar. Decide by what the screen is for.