# Easy way to find nearest text anchor in HTML page?

**URL:** <https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162>\
**Category:** Factual Questions\
**Created:** [November 4, 2007, 3:54am UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162 "2007-11-04T03:54:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ambushed](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@ambushed](https://boards.straightdope.com/u/ambushed)\
**Post date:** [November 4, 2007, 3:54am UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162/1 "2007-11-04T03:54:35Z")

</div>

I have frequently felt the need to provide URL links to portions of text well within a long web page. Often, the authors of those pages helpfully include HTML anchors within the text that you can add to an URL (preceded by a #).

Is there a way I can easily find the nearest such anchor if the author doesn’t provide any obvious hint to their existence, let alone their location? The only way I’ve found to do it is to manually view the page’s source HTML myself, which is not always very easy.

Are there any easier ways?

---

<div class="post-metadata">

**Author:** ![mhendo](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mhendo/32/3159_2.png) [@mhendo](https://boards.straightdope.com/u/mhendo)\
**Post date:** [November 4, 2007, 4:26am UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162/2 "2007-11-04T04:26:00Z")

</div>

I’m not sure why you would find it hard to view the HTML source code. That’s a pretty straightforward operation.

Anyway, if you want to find anchors without viewing source code, and you’re using the Firefox browser, there’s a very easy solution. Install the [Web Developer](https://addons.mozilla.org/en-US/firefox/addon/60/) extension, and once it’s installed, open the toolbar and select **Information \> Display Anchors**.

Voila! All the anchors will be displayed in yellow on the page…

---

<div class="post-metadata">

**Author:** ![ambushed](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@ambushed](https://boards.straightdope.com/u/ambushed)\
**Post date:** [November 4, 2007, 5:53am UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162/3 "2007-11-04T05:53:37Z")

</div>

[QUOTE=mhendo]  
I’m not sure why you would find it hard to view the HTML source code. That’s a pretty straightforward operation.

Anyway, if you want to find anchors without viewing source code, and you’re using the Firefox browser, there’s a very easy solution. Install the [Web Developer](https://addons.mozilla.org/en-US/firefox/addon/60/) extension, and once it’s installed, open the toolbar and select **Information \> Display Anchors**.

Voila! All the anchors will be displayed in yellow on the page..  
[/QUOTE]  
Perfect.

Thank you!

---

<div class="post-metadata">

**Author:** ![ambushed](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@ambushed](https://boards.straightdope.com/u/ambushed)\
**Post date:** [November 4, 2007, 6:44am UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162/4 "2007-11-04T06:44:09Z")

</div>

[QUOTE=mhendo]  
I’m not sure why you would find it hard to view the HTML source code. That’s a pretty straightforward operation.  
[/QUOTE]  
Oh, viewing the source is easy. What I found difficult was locating all the anchors therein. Especially in machine-generated HTML.

But your solution puts an end to that.

---

<div class="post-metadata">

**Author:** ![Liberal](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@Liberal](https://boards.straightdope.com/u/Liberal)\
**Post date:** [November 4, 2007, 3:48pm UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162/5 "2007-11-04T15:48:33Z")

</div>

Why couldn’t you just have searched on “\<a”?

---

<div class="post-metadata">

**Author:** ![ambushed](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@ambushed](https://boards.straightdope.com/u/ambushed)\
**Post date:** [November 6, 2007, 12:41am UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162/6 "2007-11-06T00:41:01Z")

</div>

[QUOTE=Liberal]  
Why couldn’t you just have searched on “\<a”?  
[/QUOTE]  
(1) There are usually plenty more links than anchors, which would end up wasting time on useless “finds”. I’ve performed just such searches in html documents which contained hundreds of "\<a"s.

(2) Human parsing of machine-generated document files is not only highly error-prone, it is exactly the sort of thing that computers are _supposed_ to do to take the drudgery out of human work in the first place.

---

<div class="post-metadata">

**Author:** ![GuanoLad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/guanolad/32/42_2.png) [@GuanoLad](https://boards.straightdope.com/u/GuanoLad)\
**Post date:** [November 6, 2007, 10:42am UTC](https://boards.straightdope.com/t/easy-way-to-find-nearest-text-anchor-in-html-page/425162/7 "2007-11-06T10:42:07Z")

</div>

[QUOTE=Liberal]  
Why couldn’t you just have searched on “\<a”?  
[/QUOTE]

On this page you’re reading, as an example, there are at least 125 links, both external and internal anchors. And with every new post more get added. That’s a lot to search through using the ctrl-f method.
