Reputation: 21
How can I put an href tag with link to a specific h1 tag in another page? This is what I tried...
<a href="page2.html/subject 2">Move to page 2, section 1</a>
Thanks
Upvotes: 1
Views: 3724
Reputation: 1290
Add page link to href with additional reference to the id of the specific div containing the heading(h1).
<a href="page2.html#mydiv"> Click to move to next page heading </a>
Here, page2.html is the link to next page and mydiv is the id of the div in which h1 is present.
<div id="mydiv>
<h1> My Heading </h1>
</div>
P.S: You can use the same approach to scroll to different parts on the same page.
Use target='_blank' if you want to open the next page in a new tab.
Upvotes: 0
Reputation: 530
First of all you have to give unique id to h1 tag on page2.
<a href="page2.html/subject 2#firstH1">Move to page 2, section 1</a>
Where #firstH1 is the id given to h1
Upvotes: 1
Reputation: 1480
You can do something like this:-
<div id="anchor-name"> <h1>Heading goes here </h1></div>
and refer to it later with
<a href="http://server/page.html#anchor-name">Link text</a>
Upvotes: 6