A fixed header covers content because position:fixed removes the header from normal document flow. The content below it does not automatically move down, so the first section, page title, or anchor target can slide underneath the header.
Fixed Header Layout Fix
Why Is My Fixed Header Covering Content?
A fixed header can look normal at first, but then the hero title sits behind it, anchor links land too high, or the top of the page feels hidden. The browser is not making a mistake. A fixed element is pinned to the viewport and no longer reserves layout space in the document.
- Fixed header overlap
- Anchor link offset
- Sticky vs fixed layout
What the bug looks like
The page title hides behind the header, the hero looks cut off, or clicking a menu link lands with the heading covered.
Why it happens
Fixed elements do not reserve space in normal layout. The content starts at the top as if the header were not there.
What fixes it
Add a deliberate top offset, handle anchor scrolling, adjust mobile header height, or use position:sticky when it fits the layout better.
The simple rule behind fixed header overlap
A fixed header is removed from normal document flow. That means the browser paints the header on top of the viewport, but the next section still begins where it normally would: at the top of the page.
This is why the first heading can look like it disappeared. It is usually not missing. It is sitting underneath the header.
The fastest fix is to measure the real header height and create a matching offset for the content and scroll targets.
The content has no top offset
This is the classic fixed header bug. The header is fixed to the top of the viewport, but the main content still begins at the top of the document.
Broken code
No offset.site-header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 80px;
z-index: 100;
}
main {
/* no top offset */
}
Broken visual result
Correct code
Add top offset.site-header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 80px;
z-index: 100;
}
main {
padding-top: 80px;
}
Fixed visual result
The header height is duplicated in several places
Hard-coding the same header height in multiple rules works at first, but it becomes fragile. If the header height changes, one value is easy to forget.
Broken code
Repeated values.site-header {
height: 80px;
}
main {
padding-top: 80px;
}
section {
scroll-margin-top: 96px;
}
Broken visual result
Correct code
Single source of truth:root {
--header-height: 80px;
--header-offset: calc(var(--header-height) + 16px);
}
.site-header {
height: var(--header-height);
}
main {
padding-top: var(--header-height);
}
section {
scroll-margin-top: var(--header-offset);
}
Fixed visual result
Anchor links land behind the fixed header
You may fix the top of the page and still have broken in-page navigation. The browser scrolls the target to the top of the viewport, where the fixed header is waiting.
Broken code
No scroll offset<a href="#features">Features</a>
<section id="features">
<h2>Features</h2>
</section>
Broken visual result
Correct code
Scroll marginsection,
h2,
h3 {
scroll-margin-top: 96px;
}
Fixed visual result
The mobile header is taller than the desktop header
A header that is 72px on desktop may become 112px on mobile after nav items wrap or a second row appears. If the offset stays desktop-sized, mobile content gets covered.
Broken code
Desktop-only offset:root {
--header-height: 72px;
}
main {
padding-top: var(--header-height);
}
Broken visual result
Correct code
Responsive offset:root {
--header-height: 72px;
}
@media (max-width: 768px) {
:root {
--header-height: 112px;
}
}
main {
padding-top: var(--header-height);
}
Fixed visual result
Using fixed when sticky would be simpler
Many fixed header bugs happen because the header did not need to be fixed in the first place. If the header only needs to stick after reaching the top, position:sticky can be cleaner.
More fragile code
Fixed requires offset.site-header {
position: fixed;
top: 0;
height: 80px;
}
main {
padding-top: 80px;
}
Fixed header behavior
Alternative code
Sticky header.site-header {
position: sticky;
top: 0;
z-index: 100;
}
Sticky visual result
Fast practical rule
If a fixed header covers content, do not guess random margins. Measure the real header height, offset the content intentionally, and protect anchor links with a scroll offset.
Recommended baseline
Fixed header foundationThis baseline keeps the header height, page offset, and anchor offset connected through custom properties.
:root {
--header-height: 80px;
--anchor-offset: calc(var(--header-height) + 16px);
}
.site-header {
position: fixed;
inset: 0 0 auto 0;
height: var(--header-height);
z-index: 100;
}
main {
padding-top: var(--header-height);
}
section,
h2,
h3 {
scroll-margin-top: var(--anchor-offset);
}
@media (max-width: 768px) {
:root {
--header-height: 104px;
}
}
Why this baseline helps
scroll-margin-top keeps headings from landing behind the header.
Debug checklist
- Check whether the header uses
position:fixed. - Measure the actual rendered header height in DevTools.
- Add matching top padding to
main, the content wrapper, or the first section. - Check whether the header height changes on mobile.
- Test in-page anchor links like
#features,#pricing, or#faq. - Use
scroll-margin-toporscroll-padding-topfor anchor navigation. - Check whether a fixed header is really needed or whether
position:stickyis enough. - Avoid random margin guesses that only work at one screen size.
z-index when the real problem is that the content starts under the header.
When z-index is also involved
Sometimes the header covers content and also sits above dropdowns or modals. In that case, you may be dealing with a layering problem too.
If the issue involves elements appearing behind each other, read Why is my z-index not working?.
When responsive layout is the real problem
If the header only covers content on mobile, the layout may need a mobile-specific header height or responsive offset.
If multiple sections are breaking on mobile, read Why is my responsive design not working?.
When absolute elements are also misplaced
Fixed headers, dropdowns, badges, and menus often appear together. If an overlay is not only covered but also positioned in the wrong place, the parent positioning context may be wrong.
If that sounds familiar, read Why is my absolute positioned element in the wrong place?.
When overflow creates side effects
A fixed header can make layout issues more visible, but horizontal overflow usually comes from a wide element elsewhere on the page.
If the page also scrolls sideways, read Fix overflow causing horizontal scroll.
Final takeaway
A fixed header covers content because it is removed from normal document flow. The page content does not automatically reserve space for it.
Fix the layout by adding a top offset that matches the header height, using scroll offsets for anchor links, adjusting the value on mobile, and considering position:sticky when a fully fixed header is not necessary.
Once the content and scroll targets know the header exists, the overlap bug becomes predictable and easy to avoid.
Need more layout fixes?
Browse the responsive cluster or jump back to the full FrontFixer library to keep debugging faster.