This question is not about computer hardware or software, within the scope defined in the help center.
Closed 6 years ago .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.
1,549 1 1 gold badge 22 22 silver badges 28 28 bronze badges asked Jan 25, 2012 at 2:24 Anderson Green Anderson Green 6,702 16 16 gold badges 56 56 silver badges 78 78 bronze badges I wish there was a way to link to a specific position using pixels in the URL. Commented Jan 5, 2018 at 12:02Yes there is (now). See this answer on StackOverflow. Previously, we could link to a precise spot on the webpage if there was an ID close by. But this new feature (as of Feb 2020) allows one to specify a text string. See the link for more info.
Commented May 27, 2022 at 13:15You can scroll to a given position using the jQuery scrollTo plugin. If you have a look on its demo page, you'll see that the plugin is capable of many different options, including scrolling to a certain position. That would mean you'd have to control the target's JavaScript, though, so this might not be suitable for a link to an external site.
answered Jan 25, 2012 at 4:41 Amos M. Carpenter Amos M. Carpenter 1,617 2 2 gold badges 15 15 silver badges 23 23 bronze badgesThe vanilla way link to somewhere in-page is via an anchor point already present in the page.
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 element.
answered Jan 25, 2012 at 4:31 60.5k 19 19 gold badges 154 154 silver badges 171 171 bronze badgesSimilar to Paul's answer, you can also link to the first occurrence of a tag ID in an HTML document. This won't be an exact number of pixels though.
For example, link/scroll to this page's question or answers.
answered Jan 25, 2012 at 5:02 Mike Fitzpatrick Mike Fitzpatrick 17.2k 4 4 gold badges 48 48 silver badges 50 50 bronze badgesTry right-clicking and Inspecting Elements on the page. You'll find the tags, those are the anchor points.
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 382094
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.