WordPress.org

Ready to get started?Download WordPress

Forums

Adding a link to content on the same page (2 posts)

  1. tangerine3
    Member
    Posted 2 years ago #

    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/

  2. Maeve Lander
    Member
    Posted 2 years ago #

    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>

Topic Closed

This topic has been closed to new replies.

About this Topic