How do you link (with <a>
) so that the browser goes to certain subheading on the target page as opposed to the top?
views:
62answers:
6
+4
A:
If there is an <a name="foo">
tag or any tag with an id
(e.g., <div id="foo"
>), then you can simply append #foo
to the URL. Otherwise, you can't arbitrarily link to portions of a page.
Here's a complete example: <a href="http://example.com/page.html#foo">Jump to #foo on page.html</a>
Daniel DiPaolo
2010-05-14 15:01:25
A:
You have two options:
You can either put an anchor in your document as follows:
<a name="ref"></a>
Or else you give an id to a any HTML element:
<h1 id="ref">Heading</h1>
Then simply append the hash #ref
to the URL of your link to jump to the desired reference. Example:
<a href="document.html#ref">Jump to ref in document.html</a>
Daniel Vassallo
2010-05-14 15:02:10
A:
Here is how:
<a href="#go_middle">Go Middle</a>
<div id="go_middle">Hello There</div>
Sarfraz
2010-05-14 15:02:27
You what? You've got a closing `</a>` after an opening `<div ...>` - not really sure what you're trying to do here.
Dominic Rodger
2010-05-14 15:06:01
i copied my line of link and pasted below and forgot to close the div. Thanks anyways.
Sarfraz
2010-05-14 15:08:24
+3
A:
You use an anchor and a hash. For example:
Target of the Link:
<a name="name_of_target">Content</a>
Link to the Target:
<a href="#name_of_target">Link Text</a>
Or, if linking from a different page:
<a href="http://path/to/page/#name_of_target">Link Text</a>
Michael Aaron Safyan
2010-05-14 15:02:30
+1
A:
Just append a hash with an ID of an element to the URL. E.g.
<div id="about"></div>
and
http://mysite.com/#about
So the link would look like:
<a href="http://mysite.com/#about">About</a>
or just
<a href="#about">About</a>
Felix Kling
2010-05-14 15:03:19