WooCommerce and Divi: how to override !important CSS

I am a big fan of Elegant Themes, but a lot of CSS styles (mainly in Divi) contain “!important” in order to override WooCommerce styles when using the two in a combo. Now, the big problem is that we can’t override !important with another !important. Divi will win. But no matter whether Divi has been developed in a good or not so good way, there is something we can do. (NOTE: using !important is a horrible thing in CSS. Use at your own risk)

Example: the add to cart message in Divi/WooCommerce

As you can see from the screenshot, the message bar that appears in Divi once you add a single product to cart has a specific background color, which is the one you choose in Divi / theme settings.

The CSS is:

.woocommerce a.button.alt, .woocommerce-page a.button.alt, .woocommerce button.button.alt, .woocommerce-page button.button.alt, .woocommerce input.button.alt, .woocommerce-page input.button.alt, .woocommerce #respond input#submit.alt, .woocommerce-page #respond input#submit.alt, .woocommerce #content input.button.alt, .woocommerce-page #content input.button.alt, .woocommerce a.button, .woocommerce-page a.button, .woocommerce button.button, .woocommerce-page button.button, .woocommerce input.button, .woocommerce-page input.button, .woocommerce #respond input#submit, .woocommerce-page #respond input#submit, .woocommerce #content input.button, .woocommerce-page #content input.button, <strong>.woocommerce-message</strong>, .woocommerce-error, .woocommerce-info {
background: #71b1d6 !important;
WooCommerce + Divi = CSS troubles!

Sure, it’s so simple then! Let’s override Divi !important CSS…

In your child theme stylesheet or custom CSS, you would think that the following is enough:

.woocommerce-message {
background: WHITE !important;

…but no, it doesn’t work. Unfortunately !important doesn’t “beat” !important because the parent theme will win in this case.

Let’s change core files or override !important…

The ideal, long-term solution is: Divi should change how they apply their CSS. But in the meanwhile, let’s override its !important with a little CSS trick.


.woocommerce-message {
background: WHITE !important;


.woocommerce .woocommerce-message {
background: WHITE !important;

As you can see, you can override an !important with another !important, but only if you add a more specific CSS element. In our example, we used “.woocommerce” in front of “.woocommerce-message”.

This will work!

Where to add custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my guide "Should I Add Custom Code Via WP Editor, FTP or Code Snippets?" and my video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

14 thoughts on “WooCommerce and Divi: how to override !important CSS

  1. What if there already is a value given with “!important” in the divi core css?
    Im trying to declare my footer width because its going to 46% at 981px width for some reason..
    I tried with “!important” but the core css already has it declared with it.
    Do you have any thoughts?

    1. Try to still use !important and also prepend “body” or “html” to your CSS call

  2. Thank you so much! That worked for me.

    1. Nice!

  3. Hi Rodolfo,
    Your CSS still works! Thanks! I too had white on white so I changed the background to red. Unfortunately the background for the View Cart button remained white. That button is there only if I add an item to the cart then manually open the cart.
    I messed around with the CSS until this worked:

    /* Make the background for the button in messages on the checkout form match background */
    .woocommerce .button {
    background: RED !important;

  4. Hello Rodolfo, thanks for the tutorial.

    Unfortunately, i couldnt change the background color.

    I tried with !important, without it. With the .woocommerce .woocommerce-message and without .woocommerce too. And nothing worked. And the weird thing for me is that i don’t even see an !important tag on the css. This is the CSS that i see when i inspect element:

    .woocommerce .woocommerce-error, .woocommerce .woocommerce-info, .woocommerce .woocommerce-message {
    background: #2ea3f2;

    I also tried using the exact same CSS, just changing the color and adding !important and it didnt work.

    Im using Divi theme. And i tried putting the CSS in the CSS box in theme settings and also putting it in the child theme CSS file.

    Thanks for your help

    1. Manuel, thanks so much for your comment! Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

  5. You sir should get the goddamn Nobel prize!!!! Thanks for the help Buddy!

  6. Hi,

    Just wanted to say I used this tutorial and fixed my issue perfectly.

    When I added a single product the add to basket button was white background with white text 🙁

    This fixed it up a treat, so thank you!



    1. Nat, awesome, thanks so much for your feedback!

  7. Hi Rodolfo!

    Firstly, thank you for this amazing post https://businessbloomer.com/woocommerce-divi-override-important-css/

    After following these steps I was able to customise my template. The issue this creates is the background colour I chose is the same as the automatic font colour.

    Can you please help me to change the colour of the font in the error messages?

    Your help would be amazing 😀


    1. Darius, thanks for your comment and kind words! If you give me your website link I’ll take a look and give you a fix (also, let me know what error message you’re talking about). Cheers 🙂

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

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