Does anyone know how I can create a deeplink to a subsection of an individual web page?
Wiki seem to have it cracked but I can't seem to find the answers anywhere on the web.
PS: keep it simple!
Linking to a specific location or element on a page is possible only if the destination contains markup that constitutes a “destination anchor” that you can use in a fragment identifier (starting with #
) in a link. The following create such anchors:
id
attribute (on any element)name
attribute on an a
elementThe former is the modern, preferable way and lets you refer to an element, not just a location (point) or just an inline element. For example, if the destination page http://www.example.com/stuff.html contains
<div class="section" id="sec7">
<h2>Foo bar</h2>
<p>Some text.</p>
Any other content
</div>
then you can use a link like
<a href="http://www.example.com/stuff.html#sec7">Foo bar</a>
Suppose you wanted to begin a document with a table of contents that would link people to text that appear s later in the document. Your index would include the following:
<a href="#pt1">Part I</a> <a href="#pt2">Part II</a>
Later in the document, you will include the following tags:
<a name=pt1></a> and <a name=pt2></a>
Reference: Links and Anchors
EDIT:
Where ever you want to insert a link, write this:
<a href="http://yourpage.com#pt1">Part I</a>
Here http://yourpage.com
would be replaced by the actual url to your page. Now in the code for your page, insert a tag at the point that you want your link to point to.
<a name=pt1></a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With