How to Make a Divi Accordion All Closed by Default – Divi 5 & Divi 4

Written by Dan Mossop

By default, the Divi Accordion module opens the first accordion item when the page loads. If you want a cleaner FAQ, pricing, product details, or documentation layout, you may prefer all accordion items to start closed instead.

Quick answer: To make a Divi Accordion module start all closed, open the Accordion module settings and set Design → Toggle → Initial State to All Closed. This option is added by Divi Booster. Alternatively, you can use a jQuery snippet to remove Divi’s default open state from the first accordion item.

Recommended: Use Divi Booster if you want to make accordions start all closed from the normal Accordion module settings, without adding or maintaining custom jQuery.

Watch the walkthrough below to see both methods in action:

YouTube video

This guide works with both Divi 5 and Divi 4. It shows you how to set the accordion module all closed on load using these two methods:

  • Divi Booster – No-code setup, easier future changes, Divi 5 / Divi 4 compatibility
  • jQuery – One-off custom code changes, if you are comfortable maintaining snippets

Note: This guide covers making the Accordion module start closed on page load. If you want visitors to be able to close an already-open accordion item after clicking it, see the related guide on making Divi accordion items closeable.

Before and After

The example below shows the difference. On the left, Divi’s default Accordion module opens the first item automatically. On the right, the accordion starts with every item closed, creating a more compact layout on page load.

Divi accordion closed by default before and after example

How to Make a Divi Accordion Closed by Default Using Divi Booster

Divi Booster adds an Initial State option to the standard Accordion module settings, letting you choose whether the accordion starts in Divi’s default state, all closed, or all open. Here’s how to use it to make a Divi accordion start closed by default.

Install and Activate Divi Booster

First, install and activate Divi Booster on your site. This adds the Initial State option to Divi’s Accordion module, so you can set the accordion to start all closed without editing code.

Get Divi Booster

After activating Divi Booster, open the page containing your Accordion module and follow the steps below.

Open the Accordion Module Settings

Locate the accordion module you want to modify, or add it to your layout if you haven't already. Then, hover over the module to reveal the module buttons. If your Divi Builder is set to use "Click" mode, you may need to click on the module instead of hovering. Click the "Gear" icon to open the module's settings.

Accordion module settings button shown in Divi 5

Go to "Design → Toggle → Initial State"

Now, in the Accordion module settings, click on the Design tab and then on the "Toggle" to expand the Toggle settings. You should now see the "Initial State" option added by Divi Booster.

Divi Accordion All Closed Initial State setting - default value

Choose "All Closed"

If you click on the "Initial State" select box, you'll see three options. "Default" just gives you the standard accordion module behavior – it leaves the first toggle open as normal. "All Closed", which is what we want here, makes the Divi accordion module start with all of its toggles closed. There's also "All Open" which makes the accordion start with all of the toggles expanded. Click on "All Closed" to set the initial accordion module state to all closed.

Divi Accordion Initial State All Closed setting

Save and View the Result

Now save the module settings. Note that the initial state setting doesn't show in the visual builder preview. To see the result, save your page or post and view it on the front-end. You should now see that your accordion module starts with all of its toggles closed. 

Divi accordion closed by default example

After a visitor opens one item, the module behaves like a normal Divi accordion: opening another item closes the previously open one.

Tip: Want every Accordion module on the site to start closed? Divi Booster also includes a global option under Divi → Divi Booster → Modules → Accordion.

Continue Customizing Your Accordion

Once your accordion starts all closed, the next useful improvement is usually to control how visitors interact with it. You may also want to:

How to Make a Divi Accordion Start All Closed Using jQuery

If you are comfortable adding custom code to your site, then it is possible to make a Divi accordion start closed using jQuery. This is useful if you only need a one-off code solution. However, because it depends on Divi’s accordion markup and CSS classes, you may need to retest it after major Divi updates. That said, let's see how it can be done.

Open the Divi Theme Options

Divi's Theme Options include various settings for configuring Divi, including the option to add custom code. To open the theme options, from your WordPress dashboard, click on "Divi" in the sidebar menu, then the "Theme Options" sub-menu item.

Navigate to the "Add Code to the Head of your Blog" Setting

Now click on the "Integration" tab in the Divi Theme Options, which brings up options for adding custom code to Divi. You should see a box called "Add code to the < head > of your blog" which allows HTML, JavaScript and jQuery code to be added to your site:

Divi Theme Options "Add code to the head of your blog" location

Add jQuery Code to the Site

The jQuery code below will enable the accordion toggle closing functionality to your site. Paste it into the "Add code to the < head > of your blog" box then click "Save Changes" to save the Divi Theme Options.

Prefer not to maintain custom code? The Divi Booster method above adds this as a built-in Accordion module setting, so you can change the initial state directly in Divi instead of editing jQuery.

<script>
jQuery(function($){
    $('.et_pb_accordion.accordion-all-closed .et_pb_toggle_open').addClass('et_pb_toggle_close').removeClass('et_pb_toggle_open');

    $('.et_pb_accordion.accordion-all-closed .et_pb_toggle').click(function() {
      $this = $(this);
      setTimeout(function(){
         $this.closest('.et_pb_accordion.accordion-all-closed').removeClass('et_pb_accordion_toggling');
      },700);
    });
});
</script>
Close all Divi accordions on load code added to Divi

Open your Accordion Module's Settings

Locate the accordion module you want to have fully closed on initial load, or add it to your layout if you haven't already. Then, hover over the module to reveal the module buttons. If your Divi Builder is set to use "Click" mode, you may need to click on the module instead of hovering. Click the "Gear" icon to open the module's settings.

Accordion module settings button shown in Divi 5

Add the "accordion-all-closed" Class to Your Accordion Module

In the Accordion Settings, click on the "Advanced" tab.

If you're using Divi 5, expand the Attributes settings group, click Add Attribute, set the attribute name to class, and enter accordion-all-closed as the value. Then close the Edit Attribute modal.

If you're using Divi 4, expand the "CSS ID & Classes" settings section. There you should see a "CSS Class" field. Enter accordion-all-closed into this field and then save the module settings.

Add an accordion module all closed class in Divi 5

Save and View the Result

Now save the module settings. Note that the code won't apply in the visual builder preview. To see the result, save your page or post and view it on the front-end. You should now see that your accordion module starts with all of its toggles closed. 

Divi accordion all closed example

Optional Next Steps

The jQuery method will make the selected accordion start closed, but it does not add a visual setting inside Divi. If you later want easier control over accordion behavior, you may want to use Divi Booster’s Accordion module options instead. You can also continue with these related guides:

Troubleshooting: Divi Accordion Still Opens the First Item

If your Divi accordion still opens the first item after following the steps above, check the following:

Clear your caches. If you use a caching plugin, CDN, or Divi’s static CSS cache, clear those caches and reload the front end of the page.

Check you are viewing the front end, not only the Visual Builder. The closed state may not appear in the Visual Builder preview. Save the page and view it normally.

Make sure the class is added to the Accordion module, not an individual accordion item. For the jQuery method, the accordion-all-closed class needs to be added to the module’s CSS Class field.

Check for other accordion scripts. Other snippets or plugins that change accordion behavior may override the initial state.

Confirm the module is an Accordion module, not separate Toggle modules. Divi Toggle modules already have their own open / closed state setting, while Accordion modules behave differently by default.

FAQs

Can I make a Divi Accordion module start with all items closed?

Yes. Divi opens the first Accordion item by default, but you can make the Accordion module start all closed using Divi Booster’s Initial State setting or by adding a small jQuery snippet.

Does Divi have a built-in setting to make Accordion items all closed?

Divi’s Accordion module does not include a native “all closed by default” option. Divi Toggle modules have an individual open / closed state setting, but the Accordion module normally starts with the first item open.

What is the difference between making an accordion all closed and making it closeable?

Making an accordion all closed controls its state when the page first loads. Making it closeable controls whether visitors can close an open accordion item after they have clicked it.

Can I make all Divi accordions on my site start closed?

Yes. Divi Booster includes a global Accordion module option under Modules → Accordion that can make accordions start closed site-wide.

Does this work in Divi 5 and Divi 4?

Yes, the Divi Booster method is intended for Divi 5 and Divi 4. If using custom jQuery, test after Divi updates because custom code may need maintenance.

Can I make the accordion closed on mobile but open on desktop?

Yes, but it requires a workaround. You can create two synchronized global copies of the same Accordion module, disable syncing for the Initial State and Visibility settings, then show one version on desktop and the other on mobile/tablet with different initial states.

Conclusion

Making your Divi Accordion module start all closed is a simple way to keep FAQ sections, pricing details, product information, and documentation pages cleaner on first load. If you want the easiest setup, Divi Booster adds the Initial State option directly to the Accordion module, so you can choose All Closed, All Open, or Divi’s default behavior without maintaining custom code. From there, you can keep refining the user experience by making accordion items closeable, adding open / close all controls, or improving the scroll behavior of long accordion sections on mobile. If there’s another accordion behavior you’re trying to create, ask in the comments and I’ll try to point you in the right direction.

Customize Your Divi Site with Ease

Take full control over your Divi accordions with Divi Booster. Easily set the initial state of your accordion modules to start closed, open, or default, straight from the settings. No jQuery necessary - simplify your customization process with Divi Booster's enhanced options.

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, 

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

126 Comments

  1. Hi Dan –
    Thanks so much for this!
    I am running into an issue on one of my pages where I'm using a PDF embedder in my accordions and they are refusing to resize. None of the fixes I've found thus far have worked, including the suggested fix by the plug-in developer –
    window.dispatchEvent(new Event('resize'));
    Would you be able to help? The page in question lives here currently: http://test.alexandriamasters.com/team-records/

    Reply
      • you're amazing, worked like a charm. thanks!

        Reply
        • Great! Thanks for letting me know, Stephanie :)

          Reply
  2. Hi I am looking to make it so all toggles are closed on start and then to open one then when I open the second it closes that first one opened. When I include your code it starts with all closed then I am able to open one. But then all others will not open and I cannot close the first one. Plus it does this to all of the accordions on my site not just this one on this page. I tried to add a class id to the module and then to the script. But it did not work. Any suggestions? Thanks so much.

    Reply
    • Hi Amber, are you still having problems with this? I just checked your site and currently I see that the accordion toggles are all closed initially. When I click on one it opens, then I can click on another (in the same accordion) which opens, closing the first. This is what I'd expect to happen with the code in place, and what I think you are trying to achieve, right? One thing to note is that you not all of the closed accordion is clickable (only a smaller area which includes the title and open icon is, but there is some unclickable area within the toggle) this is the way it is implemented in the accordion module itself and something to watch out for.

      You should be able to limit it to accordions with your "faqs" class by replacing each of the 3 instances of ".et_pb_accordion" with ".et_pb_accordion.faqs" in the above code.

      If you're still having trouble with any of it, let me know. Thanks!

      Reply
  3. I have Divi Booster. Love it. Trying to get the accordion toggles to close when you click on the toggles. Your path above says: ""Accordion Module Settings > Design > Toggle Text > Initial State" to one of "Default", "All Closed" and "All Open"."

    There isn't any thing in Toggle Except color choices for open and closed.
    I have long copy in the last of a toggle and I don't want to have to scroll all the way to the top to close it and go.

    Please advise.
    Thanks,
    Randy

    Reply
    • Hey Randy, not sure if Divi have done a bit of a rearrange of the toggles or if I did something wrong, but currently the setting is showing up under "Accordion Module Settings > Design > Title Text" (not Toggle Text). You'll find the setting near the end after all the other title text settings. It's not a great place for it, so for the next version of Divi Booster (2.9.5) I've relocated it to "Accordion Module Settings > Design > Toggle". I've updated the post accordingly. Thanks!

      Reply
  4. Thanks for the tips. I'm surprised there isn't an option to do all these in the builder. I won't recommend ET to my clients 'cos not going to make support ET my full time job.

    Reply
    • You're welcome, Martin. Totally understandable. If you do happen to find yourself working with Divi / other ET products in the future, feel free to give me a shout with anything you get stuck on.

      Reply
  5. Sorry but when I put the script in the CSS Main of the module and I received a lot of RBRACE error. What I am doing wrong? Sorry such a basic doubt.

    Reply
    • Hi Claudio, the code in this post is jQuery code, not CSS, so it won't work in the module custom CSS. Instead, it can be added anywhere that JavaScript can be added.

      To apply the code on the current page, for example, you can add a "Code" module anywhere in the page and place the code above in that module's settings in the "Code Module Settings > Content > Text > Code" field.

      To apply the code to all accordions on your site, you can add the code to the "Divi > Theme Options > Integration > Add code to the head of your blog" box.

      I hope that helps, but let me know if you still can't get it to work. Thanks!

      Reply
  6. Hi Dan,

    I am no longer able to open/close my accordions. (I was initially able to do so). Can you provide any troubleshooting tips?

    Reply
    • Hi Ashley, are you able to share a link to the page with the accordions, so that I can take a look for you? There are a few things that might cause this, so if you can share a link that should help me narrow things down for you. Thanks!

      Reply
  7. Awesome, it works correctly. I was looking for even other extensions, but thanks to that I stayed with the divi

    Reply
    • Great! :)

      Reply
  8. Hello Dan, that's great one from you. But what if I want to leave all tabs open by default, how do i go about that

    Reply
    • Hi Emmanuel, you should be able to do it with the following:

      jQuery(function($){
          $('.et_pb_accordion .et_pb_toggle_close').toggleClass('et_pb_toggle_open et_pb_toggle_close');
      
          $('.et_pb_accordion .et_pb_toggle').click(function() {
            var toggle = $(this);
            setTimeout(function(){
               toggle.closest('.et_pb_accordion').removeClass('et_pb_accordion_toggling');
            },700);
          });
      });
      

      It's worth noting that with all the tabs open, you won't be able to close any of them. If you'd like to be able to close them, you can add this code too:

      https://divibooster.com/make-divi-accordion-module-closable/

      Reply
  9. Bonjour

    pourriez-vous préciser ou l'on doit coller ce code (pas à pas, merci car je suis novice avec DIVI et wordpress)

    Reply
    • Bonjour eric,

      There are various ways to do it, but one way to add the code is:

      • Log into your main WordPress dashboard (French: "tableau de bord").
      • In the menu on the left, click on "Divi > Theme Options" (French: "Divi > Options du thème")
      • Click on the "Integration" tab
      • Locate the "Add code to the < head > of your blog" box (French: "Ajouter ligne de code à la < head > de votre blog")
      • Paste the code from this post into that box, after anything else that is in there.
      • Click "Save Changes" (French: "Sauvegarder les changements")

      I hope that helps!

      Reply
  10. I just wanted to confirm that script is working like a swiss clock. You just have to add this script in Integration section of Divi's Theme Option and to be precise – to add it in the .
    That's all – no more no less.

    Reply
    • Thanks for confirming that, Emanuel. I'm glad it worked for you. It looks like WP has stripped out part of your comment. I'm assuming you wrote: "add it in the <head>"? Thanks again!

      Reply
      • Yes Dan , you are right about stripping. Have a nice day.

        Reply
        • Great. You too, Emanuel :)

          Reply
          • Hey Dan, i already have the Divi Booster, but, i need another thing: can i go to other page with some especific accordeon part oppened. Example, i have one accordeon with 4 itens, if i click on the home page on the link 2, it goes to the page where the accordeon is and the item number 2 is already oppened. You get it?

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:

Divi Booster

About Divi Booster

Compatible with

Divi 5

Divi 4

News