WordPress.org

Support

Support » How-To and Troubleshooting » Adding a link to content on the same page

Adding a link to content on the same page

  • What code would i use if I wanted to click a line of text and it takes you to a heading on the same page.

    e.g., I want to click on “Business Hours” and it takes you to that heading down below on the same page. This is the code I have now but it is not working. It tries to take me to a page that isn’t found.

    this is the heading at the top of the page
    <a href="Business Hours"><span style="color: #330099;">Business Hours</span></a>

    this is where i want it to take me
    <a name="Business Hours"><span style="color: #330099;">Business Hours</span></a>

    http://www.chromehorserentals.com/wordpresstestsite/rental-policies/

Viewing 1 replies (of 1 total)
  • This is called an Anchor. You will find heaps of tutorials online so check those out if you want a full tutorial. It looks like you’re on the right track but just have your name attribute the wrong way round. It should look like this.

    The code you need for the heading will be:
    <a name="businesshours">Business Hours</a>

    You then need to use this code lower down the page where you want it to end up:
    <a href="#businesshours">Business Hours</a>

Viewing 1 replies (of 1 total)
  • The topic ‘Adding a link to content on the same page’ is closed to new replies.