Reputation: 2995
So I have a long piece of text on a webpage. What I want to do is have an inventory with links to the different headers in that text so for example when I click on "Information" it automatically jumps to the header called "Information" in the text. Can't really find how I can achieve this.
Can anyone link me, or tell me if it's short how to do this?
Upvotes: 0
Views: 1500
Reputation: 21050
You do it with 'a' tags.
Your link:
<a href="#header1">link to header number one</a>
Your header:
<a name="header1"></a>
<h1>Header Number One</h1>
Upvotes: 0
Reputation: 7969
You just need to put an unique id like:
<a href="#info">get me to the information</a>
<p><a name="info"></a>Information</p>
Upvotes: 0
Reputation: 8949
For this purpose can be used href
and name
/id
attributes of html tags:
<h1><a href="#section1">Go to Section1</a></h1>
<h1><a href="#section2">Go to Section2</a></h1>
....
....
....
<p><a name="section1">Section1</a></p>
....
....
....
<p id="section2">Section2</p>
....
....
....
Upvotes: 0
Reputation: 11431
You can use hash tags to do this.
In your text you would have headings with id's like so:
<h1 id="info">Information</h1>
Then for a link you want to jump to this section you would write:
<a href="#info">Go to info</a>
The important thing to note is the #IDHERE
in your anchor
Upvotes: 2