Large empty gaps between your header and the page content are a common Shopify theme annoyance β especially on mobile. This guide shows easy, safe fixes you can copy & paste into your theme CSS to remove that white space and get a tight, professional layout.
π Step 1 β Inspect & identify where the space comes from
Before changing code, find the element creating the gap:
- Open your store in Chrome (or any browser)
- Right-click the empty area β Inspect
- Hover the header and the first content element to see margins/padding highlighted
- Look for suspicious CSS like
margin-top,padding-top,min-height, or large empty wrappers
Typical culprits: header wrappers with bottom margin, #MainContent with top padding, empty sections, or a sticky-header offset applied twice.
π Step 2 β Add a universal CSS fix (safe, non-destructive)
Open Online Store β Themes β Edit code β assets β base.css (or theme.css) and paste this near the bottom. This resets most unwanted spacing without removing theme files.
/* Remove extra white space below header and reset content offset */
.header-wrapper,
.site-header,
.header {
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
main,
#MainContent {
margin-top: 0 !important;
padding-top: 0 !important;
}
This removes forced spacing added by theme defaults or copied custom CSS.
π± Step 3 β Mobile-only fix (if space appears only on phones)
If the gap shows only on small screens, add the mobile-specific snippet:
/* Mobile spacing fix */
@media (max-width: 768px) {
.header-wrapper,
.site-header,
.header {
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
#MainContent,
main {
padding-top: 0 !important;
margin-top: 0 !important;
}
}
π§© Step 4 β Fix sticky header offset problems
Sticky headers sometimes add an offset to avoid overlap, but that offset can be incorrect. Use a variable-based safe fix (non-destructive):
/* Correct sticky header offset (uses header-height variable if available) */
body.has-sticky-header #MainContent,
body.has-sticky-header main {
padding-top: var(--header-height, 0px) !important;
}
/* If you know your header height, set it explicitly (adjust values) */
@media (min-width: 992px) {
body.has-sticky-header #MainContent { padding-top: 80px !important; }
}
@media (max-width: 991px) {
body.has-sticky-header #MainContent { padding-top: 60px !important; }
}
If your theme already uses a header-height CSS variable, the first block will safely apply the correct offset. Only use explicit pixel values if you're sure about your header height.
π§Ή Step 5 β Hide empty sections that cause gaps
Sometimes the Theme Editor includes empty (placeholder) sections that render blank space. Hide them automatically:
/* Hide empty Shopify sections to avoid blank spacing */
.shopify-section:empty {
display: none !important;
}
This removes layout boxes that have no content.
π Step 6 β Quick checklist to find other causes
- Are app embeds injecting extra banners or script placeholders? (Check Customize β App embeds.)
- Did you copy custom CSS from an old theme β it may target old class names and create gaps.
- Is there an announcement bar or top promo that is hidden but still occupies space? (Check header code & app settings.)
- Are images inside the hero/banner set to a fixed height causing space? (Use responsive image styles.)
π§ͺ Step 7 β Test your changes (how to verify)
- Save changes to CSS and refresh your storefront (use Incognito to avoid cached CSS).
- Resize the browser or use Chrome DevTools β Toggle device toolbar to test mobile and tablet sizes.
- Check pages: homepage, collection, product page β sometimes only one template is affected.
- If you still see spacing, inspect the exact element highlighted and adjust that selector specifically (you may need a theme-specific selector).
β οΈ If the problem persists β targeted fixes
If the universal fixes above didn't fully remove the gap, try one of these targeted options (paste into your CSS, adjust selectors to match your theme):
/* Example: remove top padding from a theme-specific wrapper */
.template-index .page-width { padding-top: 0 !important; }
/* Example: header placeholder from an app */
.app-header-placeholder { display: none !important; }
/* Example: hero with fixed height causing spacing on mobile */
.hero-banner { min-height: 0 !important; height: auto !important; }
.hero-banner img { max-height: none !important; height: auto !important; }
Change selector names (.page-width, .hero-banner, .app-header-placeholder) to the actual classes you find in your theme's inspector.
β Final checklist before publishing
- Duplicate your theme before major edits: Online Store β Themes β β’β’β’ β Duplicate
- Apply CSS changes to the duplicated theme and preview first
- Test desktop, tablet, and mobile views
- Confirm there are no hidden empty sections left
π You're Done!
After applying these styles and checks your Shopify store should no longer show large white gaps between the header and content. If you'd like, I can generate a tailored snippet for your specific theme β tell me the theme name (e.g., Dawn, Refresh, Sense) and Iβll provide precise selectors and example values.