It’s really easy to create anchor links in Divi. The anchor link lets your visitors jump to different sections on the same page without leaving it. It’s extra useful in long Divi pages and posts.
HTML.COM defines anchor links in a comprehensive way:
The anchor element is used to create hyperlinks between a source anchor and a destination anchor. The source is the text, image, or button that links to another resource and the destination is the resource that the source anchor links to.
Join +4 730 subscribers!
Two Examples of Anchor Links in Divi
As you can see in the video above, anchor links can be used both in navigation menus and in buttons on a page or in a post.
You can also use the Divi Text module or the default WordPress editors (Gutenberg Block Builder and the Classic Editor) to add anchor links in plain text.
When is it Appropriate to Use Anchor Links?
Anchor links are best used in long and dense pages and posts. They are also a good choice for one page websites. A good Table of Contents section is often based on anchor links as well as nifty Back to Top buttons.
Table of Contents
The links below are actually anchor links that will bring you right down to the different chapters in this post.
- Create your anchor destination in Divi
- Add an anchor link in a Divi menu
- Add an anchor link in a Divi button
- Add an anchor link in any text element
- Add a back to top anchor link in Divi
- Troubleshooting: Common anchor link mistakes
Off we go!
Step 1: Create your anchor destination in Divi
The first step is to “drop your anchor” in the location where you want your visitors to arrive. To do this, you need to add a unique ID (identifier) to a section, row or module. In the next step, we will create links that target this ID.
- Enable the Divi Visual Builder on the page where you want to add the anchor.
- Click the cogwheel to edit the element (a section, row or module) where you want to add the anchor.
- Go to the Advanced tab and open the CSS ID & Classes tab.
- Add a clear name for your anchor (for example blog or contact-us) in the CSS ID field.
⚠️ Don’t use spaces or special characters like # in your CSS ID. - Click the green button to save the settings and then save the page.
Step 2: Create your Anchor Links in Divi
Now it’s time to add the links that will send your visitors to your fresh anchor destination. The principle is simple: Just add a link to your CSS ID with a hash (#) in front of it, for example #blog or #contact-us. You can of course link to an anchor on a specific page on your Divi website by adding the slug first, for example /about-us/#contact-us. You can even deep link to an anchor on your website from an external source like an email or social media by adding your full URL followed by the #css-id, for example https://mysite.com/about-us/#contact-us.
Here are the most common use cases.
Add an anchor link in any text element
You can add anchor links as plain text links in Text modules or in posts using the Classic Editor or Gutenberg Block Editor. Just link to the CSS ID with a hash (#) in front. I’ve used a Divi Text module to create the anchor links in the Table of Contents section in this post.
- Enable the Divi Visual Builder.
- Insert a Text module.
- Add your text and highlight the text where you want to add the anchor link.
- Add the CSS ID for your anchor element the URL field. Make sure to add a hash (#) in front of the ID, for example #blog or #contact-us.
- Click OK, and then hit the green button to save your settings and save the page.
Now you can preview your text anchor link in frontend. You might need to clear your browser cache and website cache first.
Add a back to top anchor link in Divi
Adding a back to top link in Divi is a nice way to improve the user experience in long pages and posts. Here’s a handy way how to it without adding a custom CSS ID to your header. This works fine both with the old default Divi header and the Theme Builder header.
- Create a link using a button, text, footer menu, blurb or any other way you want.
- Add the URL #et-boc
- Save your settings and exit.
Now you can preview your back to top anchor link in frontend. You might need to clear your browser cache and website cache first.
Troubleshooting: 3 Common Anchor Link Mistakes
Does your anchor link lead to a dead end? Here are a few mistakes to avoid.
Mistake 1: Using the CSS Class instead of the CSS ID
It’s easy to mix up the fields CSS Class and CSS ID. Always use the CSS ID field when you create anchor links – not the CSS Class field (that is used for styling). I did actually made this mistake twice when creating this post – in a tutorial about how to create anchor links!
Mistake 2: Adding the hash (#) in the CSS ID field
Divi will automatically add the leading # when you add a CSS ID to a section, row or module. You should never add your own # when you add a CSS ID (step 1). But make sure to add the leading # when you create your anchor links (step 2).
Mistake 3: Adding identical CSS IDs on the same page
A CSS ID must be unique on a specific page or post. If you add the same CSS ID, for example blog, in two different sections on the same page, the anchor can not refer the visitor to two different locations at the same time. Always use unique CSS IDs.
That’s all for today!
I hope that you enjoyed this post. Subscribe to VictorDuse.com on YouTube and join our Facebook group for more crisp content on WordPress and web design.
👉 Related post: How to Create Custom Sticky Back to Top Designs with Divi (from Elegant Themes)
👉 Free course: Create a website from scratch with Divi
Hello Victor, once agin a very helpful, clear and well written tutorial on the essential basics of Divi and WordPress. Thanks for the troubleshooting section at the end, and the common mistakes we make when setting up anchor links. Your input is greatly appreciated, and bookmarked. Much appreciated.
Thank you for the kinds words, Rob! 🙂
Hey there!! Do you know how to adjust the position of where the anchor link jumps to? I need it to jump down about 300 px for my static menus.
There’s no string to add extra pixels to an anchor link (well maybe with some advanced JS, but that’s above my paygrade :-)). But you can try add an invisible divider with a top margin of 300 px and CSS ID. Or you can add an inline CSS ID to a text in a text module (or any other element that can process HTML) and add a CSS ID to a word, a letter or the whole text, like this:
You can add some text here.
Or you can add an “invisible space” with a CSS ID:
When I use anchor links, I find that Divi reloads my page again after everything has loaded. It’s a terrible user experience. Is there any workaround for that?
Does the reload happen in frontend or backend? Some third party plugins makes the Divi Builder reload when editing a page.
Hi,
When I add a link from a menu button to an anchor on the home page – it highlights both pages in the menu. Is there a way to only highlight the anchor link when its on that area?
I have a menu – HOME – ABOUT US – CONTACT US.
I have an section on the Home page – called About Us and I have an anchor point at that section.
If I am on a Page – it highlights that page in the menu to show the page I’m on. But as both HOME and ABOUT US are on the same page – both are highlighted. Is there a way to change this so that the ABOU US is only highlighted when I click that button?
Thanks in advance
Hi Eoin! I see what you are looking for here but it would be pretty complex so I don’t have a solution up my sleeve.
I have added anchor links with Divi, however they are flagging as an accessibility issue when I run an accessibility checker. Is there any way to make anchor links accessible?
Anchor links should not be an accessibility issue per se but perhaps the link is missing a discernible name? You can read more about how to fix it here: https://victorduse.com/blog/boost-your-accessibility-score-with-divi/
Is this the ideal way to do it if I have 1000s of anchors across 100s of articles?
Basically, we are doing news, each day has 1 post with multiple headlines. I will be making an anchor to each headline.
I don’t mind the manual labour of adding it every time, I just want to make sure there is not going to be a CSS file somewhere that gets bloated with tens of thousands of references.
In that case I would recommend a plugin that creates the tables of contents for you. Here is one that works well with Divi: https://www.elegantthemes.com/affiliates/idevaffiliate.php?id=40598&url=82631
Hi, Thanks for the great writeup! I have two issues with my menu:
1. I’ve tried to follow these instructions exactly (including the 3 troubleshooting tips), and my menu links still aren’t working properly. The CSS ID is a simple name (eg. “gallery” (without the quotes)), and the menu link is the page URL followed by “/#gallery”. Clicking the menu item takes me to the correct page, but not down to the position of “gallery.” It just stays at the top. All 15 or so sub-menus have this same issue across 3 pages. Any idea what I missed?
2. Using a special section with a column on the left side just for the menu, some of the shorter menu items are being combined into one line where they will both fit. Is there any way to force each item to a new line?
Thanks.
I found that Divi has a left column navigation pane built into it, so #2 is no longer a problem. I still haven’t solved issue with the menu links though. Any help would be greatly appreciated!
Hi Steven! It’s hard to tell without seeing the actual page. But if the CSS ID appears at more than one (1) instance of the page, the anchor link will not work. Try to inspect the page source (View > Developer > View Source in Chrome) and search for #gallery to see if you have duplicate IDs.
Thanks for the reply, Victor. I was careful when making the IDs not to duplicate any of them.
I inspected the page, and found 2 instances of the tag, both in the links in the 2 menus on the page. It doesn’t look like the module’s IDs are in the code where the each module is defined. Are they supposed to be? I confirmed that each module still has their own CSS ID in the module settings.
Thanks.
Sorry, my mistake. The anchor destination does not contain the # in the code, it should look like in this example:
div id="my-unique-css-id-here" class="et_pb_row et_pb_row_3"
So search for id=”my-unique-css-id-here” instead.
“div id=” doesn’t appear with any of my linked headings. It seems the CSS IDs were not passed from the module settings to the page code.