Subscribe On YouTube

Join other subscribers and enjoy other Divi video tutorials!

How To Add Vertical Divider Lines Between Menu Items In Divi

Nelson Miller Profile Orange
This tutorial will show you how to add vertical divider lines between menu navigation items in the Divi Menu module or the default menu.

▶️ Please watch the video above to get all the exciting details! 👆

Add Vertical Dividers To The Divi Menu Module

The first snippet here will apply to the Divi Menu module, so you probably will want to be using this in a header template in the amazing Theme Builder.

Using More Than One Menu Module

You don’t need to add any class to the module since we are targeting it, but if you want this effect to only apply to one menu module on your site, then replace the .et_pb_menu with your own CSS class and add that to the module’s CSS field in the advanced tab.

Copy and paste the code snippet below and paste it into your website.

Where To Paste The CSS Code

1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the CSS tab in the custom code window in the Divi Visual Builder.

2. Child Theme
If you are using a child theme, paste this code into the style.css file. If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.

3. Divi Theme Options Integration
Otherwise, paste this code in your Divi>Theme Options>Custom CSS code box.

If you need help understanding where to paste the code, please check out our complete guide about where to add custom code In Divi.

/*add borders to the menu items*/

.et_pb_menu nav > ul > li:not(:last-child) {
  border-right: 1px solid #2cba6c;
}


/*adjust spacing around menu items*/

.et_pb_menu li a {
  padding: 4px 20px;
}

Add Vertical Dividers To The Default Divi Menu

Even though I totally recommend using the new Divi Theme Builder and Menu module, I haven’t forgotten those of you who are still using the default header. The snippet is very similar to the one above, except the CSS property is targeting the default menu instead of the Menu module. The step here is exactly the same. Copy the code snippet below and paste it in the Divi>Theme Options>Custom CSS box.

/*add borders to the menu items*/

#top-menu li:not(:last-child) {
  border-right: 1px solid #2cba6c;
  margin-bottom: 20px;
}


/*adjust spacing around menu items*/

#et-top-navigation nav > ul > li > a {
  padding-bottom: 4px!important;
  padding-left: 20px;
}

Now you have vertical divider lines in your Divi menu!

Customize The Snippets

You may need to play around with the spacing in the snippets to fit your website. For example, you may need to change the margin and padding values to something that works better for your situation. Other than that, you should be good to go!

Be sure to check out our 20 other Divi menu tutorials!

Subscribe For More Things Like This!

At the start of each month, we send out a recap newsletter from the month before with family news, Divi news, our latest tutorials, and product news. Occasionally, if the news is too exciting to wait, we will send out another email separate from the monthly newsletter. That’s what you get when you subscribe, and of course you can unsubscribe if you are no longer interested!

Blog Post Optin

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

51 Comments

  1. Gio

    Simple and Cool!
    Thank u! 🙂

    Reply
  2. Nityia Przewlocki

    Works great–Thank you!!

    Reply
  3. Sebastian <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hi, thanks for this tutorial. What about small vertical dividers in case logo inserted in menu module? Dividers are so height as logo…do you have any idea?

    Reply
  4. Cynthia

    Thank you so much! It looks great except on the drop down menu items. Do you know how to exclude the sub-menu items for drop down menus?

    Reply
      • Nik Long

        Hey Nelson,

        Awesome article, thank you! Can you tell me the code to add divider lines to the bottom of each item in a Drop down menus also? So this code with the side dividers for the main menu, and then code for bottom dividers for the drop downs?

      • Regis

        Likewise… The code for the default menu should be #top-menu > li:not(:last-child) to avoid divider lines in the sub menus.

        Thank you for the tutorial Nelson.

  5. Janis

    Great tutorial, thank you! 🙂 Is there any way to only add the divider between the last two menu items, not between all of them? Would be very useful for language switchers. Thanks! 🙂

    Reply
  6. Natasha Chapman

    Hi thanks for the tutorial, it works for the main menu but I actually only want it on my sub menu, is there a code to do that ?

    Reply
    • Hemant Gaba

      Could you please share the URL of the page where the submenu is present for us to investigate further?

      Reply
  7. Anneloes <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    The dividers are still showing in my submenu. The last child is not showing a divider. Changing the code to “first-child” the first child is not showing a divider. That makes sense … but … how to remove the divider from al the items in the submenu?

    Reply
    • Hemant Gaba

      Hi Anneloes

      Could you please share the URL of the page for me to investigate further?

      Reply
      • Hemant Gaba

        Please remove the present code that you are using and use the code given below instead:

        #top-menu > li{
        border-right: 1px solid #ec7034;
        margin-bottom: 20px;
        }

        Let me know how it goes. 🙂

      • Hemant Gaba

        I am glad that the issue is resolved now. 🙂

  8. Leameana

    This works when I am in the theme builder but when I exit the theme builder my menu looks like a bulleted list what am I doing wrong?

    Reply
  9. nicolas

    Hello, and if i want it only at one location like here (between menu and social media icon). How can i do ?
    http://www.benjaminlycan.com/

    Reply
    • Hemant Gaba

      Hey Nicolas,

      I saw the URL provided and everything looks fine now. Please let me know if you have any other queries.

      Reply
    • Flávio Halliday

      Hiy Nicolas,

      I would like to know what CSS codes you used to do it. Did you customize some CSS classes?

      Reply
  10. Tyson

    If I wanted to make the lines a certain height, what would the css look like for that? I have the lines in place but they are too tall and I have adjusted the padding with no difference.

    Reply
  11. martijn

    Hi!

    I was wondering if there’s a way to divide by bullet points instead of vertical lines.
    Thanks in advance!

    Reply
    • Hemant Gaba

      Hey Martijn,

      Could you please share the URL of the website for me to investigate it further?

      Reply
  12. kenneth <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hi!

    I have added the custom CSS, but the lines are too tall. How can I make them as originally intended by you?. The header is a Theme Builder based header (if it makes any difference).

    The URL are: https://volkers.dk/home/ (passw: notyet2022 )

    Sincerely Kenneth

    Reply
    • Hemant Gaba

      Hello Kenneth!

      Could you please try with the given code below?

      .custom_menu li a {
      padding: 4px 20px !important;
      }
      .custom_menu ul#menu-menu-1 {
      margin-top: 20px;
      }

      Result: https://prnt.sc/66o9Vy-dOL5-

      Let me know how it goes. 🙂

      Reply
    • Hemant Gaba

      Hello David!

      Can you please try with the given code below?

      .et_pb_menu li a {
      padding: 2px 15px !important;
      }
      .et_pb_menu .et-menu-nav>ul{
      align-items: center !important;
      }
      .et_pb_menu .nav li ul.sub-menu a{
      padding: 6px 20px !important;
      }

      Here is the result: https://prnt.sc/WfjfJzxvYLAE

      Wishing you all a very happy New Year!

      Reply
      • Jason Thomas

        I am trying to find out how to get help with this blog post. Every time I create a post it disappears. Do those go to moderation or am I have a technical issues? What is the best way to get help with the tutorial?

        My issue with this post is I’m trying to determine if the vertical bar can be replaced with a “~” (tilde) character. I’m also wondering if there is a way to isolate the appearance of the menu treatment only to a few pages with a certain menu name. Can someone please help?

      • Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

        All posts go to moderation by default in WordPress yes. Also, please understand we cannot give free customization service beyond the tutorial, so sometimes we prioritize other comments. We spend many hours a week responding to comments, and it can be tiresome but we try our best. Sorry for the delay! This tutorial is using a border, so to add an actual icon it would be a little more complicated and would require a pseudo class, and it could be tricky to align it to the center of each menu item.

  13. Jason Thomas

    Is there a way to select which menu this script affects? For example, I only want it to effect the lower menu on the portfolio pages and I would like to substitute the vertical divider with a special character? I’d like to use the “–” (emdash) or a “~” (tilde).

    https://465.9ab.myftpupload.com/portfolio/

    Thanks in advance

    Reply
    • Hemant Gaba

      Hi Jason!

      I have checked the page and it seems you have already made the changes.

      Let us know if you need any further assistance with it!

      Reply
    • Hemant Gaba

      Hi Sayed!

      The page you have shared above does not exist. Can you please check it again?

      Reply
  14. Kim

    Hey, I’m using divi builder and the css works great but when I go build the post content and put in a menu in the sidebar the lines also show on it. Is it possible to make they not show up on sidebar menu in the post content. Thank youi

    Reply
    • Hemant Gaba

      Hi Kim!

      Please replace the .et_pb_menu with your own CSS class and add that to the module’s CSS field in the advanced tab.

      Reply
  15. Chris

    Thanks very much for the tutorial! It was very helpful.

    I built my global navigation in the Divi Theme Builder. I used your Module script to add the divider lines. Playing around with adding “margin-top” and “margin-bottom” in the “menu li a” code along with some spacing adjustments in the builder itself, I was able to make my two-row navigation have lines that were just about as tall as the nav text with room to space them a bit further apart so they don’t look crammed in there.

    Much appreciated!

    Reply

Submit a Comment

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

Recent Posts

0

Your Cart