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
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
Share Improve this question asked Nov 25, 2017 at 6:28 Dan SDan S 211 silver badge6 bronze badges 1- 2 Possible duplicate of How to navigate to a section of a page – ZerosAndOnes Commented Nov 25, 2017 at 6:33
3 Answers
Reset to default 6You 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>
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
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.