Adding Anchor Links to Email Content with HTML
Add a clickable table of contents or a “Back to top” link to your newsletters. This article shows the HTML code to use, with a complete example.
An anchor link lets readers jump straight to a specific section of your email, for example from a table of contents at the top to an article further down. It is especially useful in long newsletters or newsletters covering several topics (news, events, donation appeals).
In Yapla Newsletters, anchor links are created with two pieces of HTML code: an anchor, placed at the destination, and a link that points to that anchor.
Some email apps, including the Gmail app, don't support anchor links. The rest of the email displays normally, but clicking the link does nothing. Always test your email before sending it.
Add the anchor at the destination
- In the email editor, drag an HTML block just above the section the link should lead to.
- Paste the following code into the block, replacing
eventswith a short name that describes the section:
<a id="events" name="events"></a>
The anchor name must not contain spaces, accents or special characters, and must be unique in the email.
Add the link to the anchor
Where the link should appear (in a table of contents, for example), add an HTML block and paste the following code, using exactly the same name preceded by the # sign:
<p><a href="#events">See our upcoming events</a></p>
Repeat for each section: one anchor and one link per destination.
Complete example
Here is an example of a table of contents that links to two sections of the same email:
<p><strong>In this newsletter:</strong></p>
<ul>
<li><a href="#events">Our upcoming events</a></li>
<li><a href="#volunteers">Call for volunteers</a></li>
</ul>
<!-- Further down in the email -->
<a id="events" name="events"></a>
<h2>Our upcoming events</h2>
<a id="volunteers" name="volunteers"></a>
<h2>Call for volunteers</h2>
Troubleshooting
The link doesn't go anywhere
- Check that the name after the # in the link exactly matches the anchor name (including capital letters).
- Make sure no other anchor in the email uses the same name.
- Check that the name contains no spaces or special characters.
The code appears as is in the email
- Use an HTML block, not a text block.
- Check that every opening tag is closed.
The link works on desktop but not on mobile or in Gmail
- This is a limitation of the recipient's email app. Keep your sections short and clearly titled so the email stays easy to read without the links.
