Is it possible to create a hyperlink to a specific scroll position on a web page? For example, I'd like to create a link to http://www.stackoverflow.com/, but with the page scrolled down 100 pixels.
The vanilla way link to somewhere in-page is via an anchor point already present in the page.
This can be created using the
<a>…</a> tag. Note that the link specified in "anchor point" (above) has
#h-12.2 at the end. This corresponds to
<a id="h-12.2">12.2</a> embedded in the HTML forming the page, and when clicked will reposition the page view to this anchor.
Note that prior to HTML5, the
name attribute was used in the anchor tag, but is no longer supported and the
id attribute should be used in its place (reference). This also means that you can use any element for an anchor tag, you are not limited to the
Try right-clicking and Inspecting Elements on the page. You'll find the
<a> tags, those are the anchor points.
Then take out the
< before the first and last
a so that they would not show up as the links. You can actually see the effects while writing in the response box when it shows you the preview below.
a href="https://superuser.com/questions/382047/linking-to-a-specific-scroll-position-on-a-web-page#question-header">question /a>
a href="https://superuser.com/questions/382047/linking-to-a-specific-scroll-position-on-a-web-page#answers">answers /a>
As you can see, the only difference is at the very end where the anchor names after the pound (
#) symbol. the name after the
> is for how the link reads to the user.
In this case "question-header" reads as "question" and answers happens to be the same.
Then the following should link to Mike's comment. Since their anchor point is
To clarify, you can simply find the anchor and add the
# after your link.
these will all take you to different places on the same page.
You can use Citebite to link to a specific position of a webpage even if it doesn't use id in that position. It is easy to use. Just go to the link I provided here and then paste the chunk of the text you want to show first after going to your webpage in the Quote text field and then provide the link of the webpage in the Source URL text field. Then click to Make Citebite. Then it will generate a link. That link will be your desired link.