Setting the Divi Theme Sidebar Background Color

This post may contain referral links which may earn a commission for this site

The Divi Theme has a flexible sidebar which can be positioned on either the left or right of the page (or hidden altogether). Unfortunately, the way that the sidebar is structured actually makes it very difficult to set the background color with margins, etc, that actually look good. Here, then, is how to change its background color by adding some CSS to the theme.

Updated: I've recently revisited this and come up with a new method which works much more cleanly with Divi's natural flow. It can also be applied with out affecting the existing layout at all. I've included both methods here.

Method 1: The Old Way

We can start by setting our desired background color on the "sidebar" element, like so: 

For a light-grey background. Or for a semi-opaque black background:

You'll notice however, if you do this, that it doesn't look particularly good. The sidebar element tightly surrounds the content meaning that the contents of the sidebar are right up against the edge of the sidebar.

To fix this we can adjust the padding and margins. We need to specify several sets of padding and margins to handle the various screen sizes supported by Divi. Here is an example set of padding and margin rules which I think gives a nicer result:

 This code works for both left and right sidebars.


Method 2: The New, Better (But Longer) Way

Here's my preferred method of setting the Divi Theme's background color as it provides a much neater and more natural integration with Divi.

Again it works on both left and right sidebars.

Another thing you may consider doing to enhance the look of the sidebar is removing the dividing line.

Hundreds of new features for Divi
in one easy-to-use plugin


  1. Hi Dan,

    Where would I add the code in method 2? I have followed your tutorial on copying code into Divi them but can't seem to see any changes. I am using a child theme and have tried placing the css code in different parts and nothing seems to change the sidebar.

    Hope you are able to assist.

    • Hi Mike, the CSS can be added either into the Custom CSS box found at "Divi > Theme Options > General > Custom CSS", or into the "style.css" file within your child theme. Assuming neither of these is working, are you able to send me a link to the site you are working on so that I can take a look at what's going wrong? Thanks!


Submit a Comment

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