5

I want to direct my readers to a particular place in a third-party HTML webpage. The paragraph of interest looks like this:

<div>
<h1>qwerty</h1>
<p>blah blah</p>
</div>

Like you can see, none of the elements have ids (so this http://webpage/#id wouldn't work). However, the word within the <h1> tag is unique and cannot be found anywhere else in the document. Is there a way to provide a link that will take users directly to that spot on the webpage?

raul
  • 1,209
  • 7
  • 20
  • 36
  • 2
    Sure, what have you tried? – j08691 Jun 29 '16 at 20:35
  • You wan't to focus on `

    qwerty

    ` when URL is `http://webpage/#qwerty`?
    – Mohammad Jun 29 '16 at 20:36
  • There should only be one `h1` element on your webpage -- it's not required, but [search engines will expect it.](https://moz.com/community/q/how-will-it-effect-seo-to-have-multiple-h1-tags-on-a-page) – Blazemonger Jun 29 '16 at 20:43
  • [Similar question](http://stackoverflow.com/questions/23362356/highlight-given-strings-on-a-static-html-page-with-javascript) – Blazemonger Jun 29 '16 at 20:46
  • 1
    Does this answer your question? [Is there any way to bookmark or link to a section of a page without an anchor?](https://stackoverflow.com/questions/7983290/is-there-any-way-to-bookmark-or-link-to-a-section-of-a-page-without-an-anchor) – toraritte Aug 08 '20 at 16:16

2 Answers2

3

As also stated in this comment already as of 2023 you can now use so called Text Fragments in supported browsers.

the pattern is: https://example.com#:~:text=[prefix-,]textStart[,textEnd][,-suffix]

and can be created via the browser in the right click context menu, like in chrome with Copy Link to Highlight.

appending #:~:text=qwerty should do it for this case

Further answer, and possible duplicate: https://stackoverflow.com/a/61703068/731179

mxfh
  • 386
  • 1
  • 2
  • 11
0

You can't link to just some text in the page, so it's not possible if you don't control the site.

The closest thing you can do that I'm aware of is use citebite, which creates a new page with an id inserted so it can take you to that section. However, it's pretty hit or miss in my experience.

dlsso
  • 7,209
  • 1
  • 21
  • 31