Key points
- White space under the Divi header often comes from first section padding, the space Divi adds for a fixed header, or padding left in a Theme Builder header.
- Use your browser's developer tools to find the element that holds the gap before you change anything.
- Fix section padding in the Design tab first, and use a short CSS rule on the page container only for a fixed header.
- A negative margin is a last resort, and a shadow only hides the gap.
- Clear the Divi CSS cache, your caching plugin and your browser, then test on a phone.
In this article9 sectionsHideShow
To remove white space under the header in Divi, find which element makes the gap, then change that one setting. The cause is often the top padding on the first section, the space Divi leaves for a fixed header, or padding left over in a Theme Builder header.
This guide shows you how to find the cause with your browser, fix it without code where you can, and use a short piece of CSS where you cannot. You can use the same steps to look for a gap between the header and the body on other WordPress themes.
What causes white space under the header in Divi?
A gap under the header can come from the first section, the space Divi sets aside for a fixed header, or the header layout itself. Elegant Themes says that by default, Divi elements such as regular sections and rows have top and bottom padding values set (page dated 8 August 2024). A first section with its default padding will sit a little way below the header.
Fixed headers add a second cause. Elegant Themes explains that when the Fixed Navigation Bar option is on, Divi calculates a top padding value with jQuery so the fixed header does not overlap page content (page dated 8 August 2024). That padding depends on the height of the navigation, which changes with custom font sizes, logo height or other menu settings. So it is worth comparing that padding with the real height of your header.
Use this table to match what you see to a likely cause. Start with the row that fits your page.
| What you see | Likely cause | Where to change it | How to test |
|---|---|---|---|
| A gap between the header and the first section on every device | Default top padding on the first section or its row | Section settings, Design tab, Spacing | Set the top padding to 0, save and reload |
| A gap that appears only when the header is fixed | Top padding Divi adds to the page container for the fixed header | Divi, Theme Options, General tab, Fixed Navigation Bar and Custom CSS | Switch the option off briefly and see if the gap goes |
| A gap on phones only | A rule or setting that applies only at small widths | Custom CSS with a media query, or the spacing settings | Narrow your browser window or open the page on a phone |
| A gap under a Theme Builder header | Padding left on the header section, or a large top margin on the body section | Divi, Theme Builder, header layout, section Spacing | Set the header section's top and bottom padding to 0 and check the body section |
| A gap above the header only while you are logged in | The WordPress admin bar | Nothing to change | View the page in a private window |
| A header that jumps while the page loads | The fixed header padding is worked out after the page starts to show | Custom CSS with the values from your browser tools | Reload the page and watch the first second |
How do I find which element is causing the gap?
Use your browser's developer tools to see which element holds the space, so you can change the real cause. Google's Chrome documentation says the Styles tab lists the CSS rules being applied to whatever element is selected in the DOM tree (page dated 12 March 2024). It also has a box model diagram for padding and margin.
- Open the page, right-click the white space and choose Inspect.
- In the Elements panel, select the header, then
#page-container, then the first section (it has the classet_pb_section). - For each one, open the Styles tab and look at the box model diagram. Hover over the padding or margin to highlight it on the page.
- Edit a value in the panel to test it, then make the real change in Divi.
- Write down the element, the property and the value that closed the gap.
The same check works when you need to remove white space around any div. The box model diagram shows whether the space is padding, margin or the element's own height.
Margins can behave in ways you do not expect. MDN explains that the top margin of a parent collapses with the top margin of its first in-flow child unless the parent has a top border, top padding or inline content (MDN page modified 20 November 2025). So a margin on the first heading may be what makes the gap, even when the section itself has no margin.
How do I remove the gap between the header and the first section in Divi?
Set the first section's top padding to a smaller value in its Design tab. This needs no code, and it is the safest first try.
- Open the page in the Divi builder.
- Open the settings for the first section, then the Design tab, then Spacing. Elegant Themes' guide to a transparent fixed header names this route as the Section's Design tab, then Spacing, then Padding (page dated 23 March 2026).
- Set the top padding to
0, or a smaller value, and check the first row in the same way. - Save, clear your caches (see below) and reload the page.
If your header is a Theme Builder layout, check the header section too. Elegant Themes' guide to fixed headers tells you to remove all default top and bottom padding from the header section, and to do the same for the body section (post last updated 17 September 2022).
The same guide adds a point about fixed headers. A fixed header leaves no space on the page, so its example gives the body section a top margin of 150px and says you can adjust that value. If you copied that step, a margin that is too large is the first place to look.
You may have read advice to set a Header Padding value to 0px in the Divi Theme Customizer. Elegant Themes' page on the Header and Navigation settings (dated 2 January 2024) lists Header Format, logo settings, Menu Height and the fixed navigation options. It lists no header padding setting. In Divi, the route is Divi, then Theme Customizer, then Header & Navigation, and Menu Height is the setting for the height of the menu bar.
How do I fix white space under a fixed Divi header?
Set the top padding of the page container to match the real height of your header. This applies when the Fixed Navigation Bar option is on. Elegant Themes names that option under Divi, Theme Options, General tab, where it says the main header area stays fixed at the top of the browser window.
For example, suppose the browser tools show a header that is 80px tall, while #page-container has 110px of top padding. The extra 30px is your gap, so you set the padding to 80px. These figures are an example and not from a real site, so use the numbers you wrote down in the steps above.
Paste this into Divi, Theme Options, General tab, Custom CSS. Elegant Themes' page on where to add custom CSS in Divi 5 gives the same route. The screenshot at the end of this guide is an earlier one of that box, so copy the snippet below and not the image.
/* Match the space under a fixed header to the header's real height */
@media only screen and (max-width: 980px) {
#page-container {
padding-top: 80px;
}
}
Here is what each part does.
@media only screen and (max-width: 980px)applies the rule only on screens up to 980 pixels wide. Elegant Themes uses the same width in its own snippet for a fixed header on phones and tablets (page dated 9 August 2024). Delete this line and its closing brace if the gap shows on large screens too.#page-containerpicks the main wrapper around your page, which is where Elegant Themes' own example sets the top padding.padding-top: 80pxsets the space above your content. Replace80pxwith your own header height.
If the browser tools show your rule crossed out, the value may be set directly on the element. MDN says that the only way to override inline styles is by using !important (MDN page modified 22 September 2026). Add !important after the value only in that case, and leave a CSS comment saying why.
How do I fix white space under the Divi header on mobile only?
Look for a rule or setting that applies only at small widths, then fix the one that causes the gap. Elegant Themes says Divi's fixed navigation bar is not fixed on mobile devices out of the box. If you added CSS to make it fixed on phones, that CSS is the first place to look.
- Narrow your browser window below 980 pixels, or open the page on a phone, and inspect the gap as shown above.
- Check your Custom CSS box for any rule inside
@mediathat touches#page-container,#main-headeror the first section. - Check the spacing settings of the first section. If your version of Divi shows a phone view for a setting, check that view too.
- Use the snippet in the section above, and set the value to the header height you see on the phone.
Test on a real phone in a private tab once the change is saved and your caches are clear.
Does this work for white space between the header and body on any WordPress site?
The method is the same on any theme. The names and menu paths in this guide are for Divi. On another theme, inspect the gap in the same way, then change the padding, margin or height that the box model diagram points to.
Each theme uses its own class names and its own place for custom CSS, so check your theme's documentation for the right box. Divi's box is under Divi, Theme Options, General tab, Custom CSS.
Should I use a negative margin or a shadow to hide the gap?
Use these only when you cannot change the real cause. A negative margin pulls the whole page container up, so it can move things you did not mean to move. It also leaves the cause in place, so the gap can return when the header height changes.
You may see a snippet such as margin-top: -2px !important on #page-container. MDN says that using !important to override specificity is considered a bad practice and that understanding specificity and the cascade can remove the need for it. A margin without that flag is easier to manage.
If the gap is a pixel or two and you cannot find a cleaner fix, use this fallback.
/* Last resort: pulls the page up by 2px on small screens */
@media only screen and (max-width: 980px) {
#page-container {
margin-top: -2px;
}
}
The rule pulls the page container up by 2px on screens up to 980 pixels wide. To undo it, delete these lines from the Custom CSS box, save, and clear your caches.
A shadow under the header only hides a gap. MDN says that a box shadow does not impact box model dimensions (MDN page modified 16 September 2026), so the space stays exactly where it was. This snippet draws a soft shadow under the default Divi header.
/* Masks a thin gap with a soft shadow. The gap is still there. */
#main-header {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
The first two values move the shadow across and down, the third sets how soft the edge is, and the last sets the colour and strength.
Which caches do I clear after changing the Divi header?
Clear the Divi CSS cache, then any caching plugin, then your browser. Elegant Themes says Divi 5 saves much of your design as static CSS files, and that old files can keep showing old styles (page dated 10 June 2026). If images in a row also look wrong after a change, our guide to lining up images in a Divi row has a symptom table to check.
- In Divi 5, go to Theme Options and press the Clear CSS Cache button at the top right. In older versions, open the Advanced tab in the Builder theme options and press Clear (page dated 10 June 2024).
- Clear your caching plugin. If you use LiteSpeed Cache, our guide to LiteSpeed Cache settings for Divi shows how it is set up on a Divi site.
- Clear any server or CDN cache. Elegant Themes warns that a CDN can keep serving a cached page after you clear everything on the server.
- Test in a private window, or add
?nocache=1to the page address, as Elegant Themes suggests.
If the page flashes or the header jumps while loading, and the gap is not steady, read how to fix a page that flashes while loading.
If you would rather have help with your layout, First Place SEO offers Web Design. Whichever route you take, check the page in a private window on a phone and on a computer before you decide the gap has gone.
Frequently asked questions about white space under the Divi header
Why is there white space above my Divi header?
If you only see it while logged in, it is probably the WordPress admin bar. The WordPress developer reference says it adds a top margin of 32px to the page, or 46px on screens 782 pixels wide or narrower, to make room for the bar. View the site in a private window. If the gap stays, check the header's top padding.
Why does my Divi header jump when the page loads?
Elegant Themes says that with Fixed Navigation Bar on, Divi works out the top padding with jQuery, and server speed, connection speed or page complexity can delay it, so the header shifts. One fix it gives is to find the calculated values in your browser tools and set them in Custom CSS, so the space is right from the first moment.
Is there a header padding setting in the Divi Theme Customizer?
Elegant Themes' page on the Header and Navigation settings lists Header Format, logo options, Menu Height and fixed navigation options, and no header padding setting. Menu Height is the height of the menu bar. If your version of Divi shows a padding option, change one value at a time and check the result.
Can I remove the gap without writing code?
Often you can. Set the first section's top padding to 0 in the Design tab under Spacing, or set a Theme Builder header section's top and bottom padding to 0. Use CSS when the space comes from the padding Divi adds for a fixed header and the builder has no field for it.
How do I undo my CSS if the page looks worse?
Go back to Divi, Theme Options, General tab, Custom CSS, delete the lines you added and save. Clear the Divi CSS cache and any caching plugin, then reload in a private window. Copy the old contents of the box into a text file before you edit, so you can paste them back.

