This is also known as Bookmarking within a webpage.
This tip is useful when you want to display Table of Contents within a long blog post:
Let’s say the text that you want to be hyperlinked is ‘Mary had a little lamb‘. And this ‘Mary had a little lamb‘ is somewhere in the first paragraph of your webpage. This text has to be hyperlinked to the last paragraph of your webpage which has an explanation to the song. In other words, clicking on ‘Mary had a little lamb‘ will take the visitor to a location within the same page which has the explanation to the song.
Here’s how to do:
To accomplish this task, we are going to use the awesome <a> tag.
1. We will put the text to be hyperlinked within the <a> tag along with a ‘href‘ attribute, in the first paragraph of your webpage. Note that the text is preceded by a hash tag. This is very important or the trick will not work.
<a href=”#explanation”>Mary Had A Little Lamb</a>
2. We’ll scroll down to the last paragraph in our example and put the explanation too within <a> tag along with a ‘name‘ attribute. Note that the value of the ‘name‘ attribute should exactly match the value given in the ‘href‘ attribute above. Ensure to close the <a> tag without fail.
You may also use id attribute in the place of name attribute.
<a name=”explanation”>
<h3>Here is explanation to the poem</h3>
</a>
That’s it. Save, publish and check your results: linking within a webpage is that easy!
Note: alternatively, you can also use a plugin to do this job – footnotes is one such plugin.
Here’s a live example. Click here to see the last line of this post:
—————-
This space is intentionally left blank
This space is intentionally left blank
This space is intentionally left blank
————————————————–
Here’s the last line of this post
Please leave your comments and feel free to share this trick with your buddies. Thanks for visiting!
Leave a Reply