Adjusting the Divi Page-Container Padding-Top

News: Divi Code Snippet Module now supports Divi 5

Written by Dan Mossop

If you're doing customization work on the Divi Theme's header, you may find you need to adjust the top padding of the page-container div element, in order to move the rest of the page content up or down. It's relatively easy to adjust this padding, but it is not entirely obvious how to do so, so here are some examples of CSS selectors for targeting the #page-container's top padding:

/* posts and pages */
.single #page-container, .page #page-container { 
	padding-top:10px !important; 
}  

/* homepage */
.home #page-container { 
	padding-top:10px !important; 
} 

@media only screen and ( max-width:981px ) {
	
	/* mobile posts and pages */
	.single #page-container, .page #page-container { 
		padding-top:10px !important; 
	}  
	
	/* mobile homepage */
    .home #page-container { 
		padding-top:10px !important;
	} 
}

I've used the "home", "single" and "page" classes of the body element to target the homepage, posts and pages respectively.

I've used a media query to trigger mobile-specific padding when the page width falls below 981px (you may want to play around with the width at which your mobile-specific padding kicks in, but 981px is the point at which Divi stops using a floating header).

Finally, I've added !important to all the padding rules to make sure the browser uses our rules instead of the default top-padding set by Divi which would otherwise take precedence (as it is set using inline CSS).

We may earn a commission when you visit links on our website.

Master Your Divi Customizations with Ease

Elevate your WordPress site effortlessly by adding AI-driven call-to-actions with WP Magic CTAs. Generate custom CTAs for each post—including guides like adjusting Divi's page-container padding—to boost engagement and drive traffic where you need it most.

Latest Posts

Add a Branded QR Code in Divi

To create a branded QR Code in Divi, you can use the Divi QR Code module and its "Center Image" feature. This lets you add an image / logo in the center of the QR code, perfect for promoting your brand or adding a unique twist to your QR Codes. The image is displayed...

Add Text Before the Number in the Divi Circle Counter

Adding a custom number prefix to your Circle Counter lets you clarify what the value represents—such as currency, units, or labels—without relying on the default percentage format. This helps your counters better match real-world metrics and keeps the design...

Add a Second Line of Text in a Divi Button Module

Adding a second line of text beneath a button’s main label lets you provide extra context, a brief benefit statement, or a supporting call-to-action without cluttering your design. This can improve clarity and increase clicks by making the button’s purpose more...

Top (or Bottom) Align Divi Icon List Module Icons

When Icon List items wrap onto multiple lines, the default icon alignment can make the icon appear vertically centered next to the text, which may look unbalanced or harder to scan. Setting the icons to align at the top creates a cleaner, more consistent...

Make Divi Button Modules Full Width with Centered Content

This configuration makes a Divi button stretch to the full width of its container while keeping its label neatly centered, creating a bold, edge-to-edge call-to-action. You might want this for hero sections, pricing tables, or any layout where a standard-sized button...

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

9 Comments

  1. Hi Dan, is it possible to target only posts and not pages? How can I differentiate between them, in short? I need to change margin/position for my posts but keep pages untouched.
    I second putting something like that in the plugin, too :))
    Thanks in advance
    Stefano

    Reply
    • Hey Stefano, you can target posts only using the ".single" class. So, for example, the above code modified to apply to posts only would be:

      /* Adjust page container padding on posts */
      .single #page-container { 
      	padding-top:10px !important; 
      }  
      @media only screen and ( max-width:981px ) {
      	.single #page-container { 
      		padding-top:10px !important; 
      	}  
      }
      

      I've removed the bits targeting the homepage (".home") and pages (".page").

      I'll definitely try to add this into a future version of the plugin. Thanks!

      Reply
  2. Great tip. I think it relates to an issue I am having with a project I'm working on. Divi for some reason calculates top padding for the page and ends up pushing all my content down. I have tried everything I could think of off the top of my head, and no luck. Any ideas? Thanks!

    Reply
      • Hi Rob, it looks like the top padding is being set on the full-width header module itself, in response to the page container padding. If you're able to provide a link to a page showing the problem I might be able to figure out exactly what's going on / how to properly fix it. One workaround would be to manually override the padding on the header by adding something like this:

        .et_pb_fullwidth_header_0 { padding-top: 0 !important; }
        

        to the per-page Custom CSS box (which you'll find from the three-lined "hamburger" menu at the top right of the Divi Builder box on the edit screen for the affected page).

        Reply
  3. Is this a setting in Divi Booster? If not, why not?

    Love the plugin! Thanks.

    Reply
    • Hi Mike, it looks like I missed adding this one into the plugin somehow. I'll try to correct that as soon as possible. Thanks!

      Reply
  4. Hi, I am looking for information on whether there is a way to reduce the container margin on mobile phones, but on the sides as opposed to the top.

    Originally I thought it would be an option, similar to the gutter width option, but that only changed the row gutters.

    I know, I can change it with CSS, but I don't know what else it may affect. If there's no built-in option, then I will just go a CSS edit and then see what happens. Any ideas?

    Reply
    • Hi Luke, I don't think there is any option in Divi to control this. I've just been playing around with it and have come up with this:

      https://divibooster.com/changing-the-website-content-width-on-mobiles/

      As you'll see from the post, I've used CSS to change the width (which also adjusts the visible margins. I've restricted the selectors to only those needed to minimize any unwanted effects, and as the content within these container elements doesn't rely on the width (that I know of), I think it should all behave correctly. It seems to during my testing, but let me know if you notice anything untoward.

      It'll be included in the next version of Divi Booster (2.4.6), which I'll hopefully get out in the next week or so.

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

Get this feature

This feature is available in the following plugins: