The A element defines an anchor.
You can create a link to a named anchor by using the name attribute (or the id attribute).
When linking to another document, the A element is set as follows.
example1.html
<a href="example2.html#Anchorname">linked text</a>
example2.html
(Target point)
<a name="Anchorname">a named anchor</a>
| Attribute | Value | Explanation |
|---|---|---|
| href=" " | URL#anchor name | the target URL, number sign (#), and anchor name |
| name=" " | anchor name | arbitrary name |
Create a named anchor
Link to a named anchor
anchor_example1.html
<h1>Menu page</h1> <h2>Anchor example</h2> <h3><a name="menu">Menu</a></h3> <ul> <li><a href="anchor_example2.html#a001">Jump to a001</a></li> <li><a href="anchor_example2.html#a002">Jump to a002</a></li> <li><a href="anchor_example2.html#a003">Jump to a003</a></li> </ul>
anchor_example2.html
<h1>Target page</h1> <h2>Anchor example</h2> <h3><a name="a001">a001</a></h3> <p>paragraph text ...</p> <h3><a name="a002">a002</a></h3> <p>paragraph text ...</p> <h3><a name="a003">a003</a></h3> <p>paragraph text ...</p> <hr> <p><a href="anchor_example1.html#menu">Jump to Menu</a></p>