<a href="url#"><a name="">

Browser
  • IE
  • Cr
  • Sf
  • Fx
  • O
Type

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
  • Anchor names must be unique within a document.
  • Anchor names are case-sensitive.
  • The following symbols can be included in an anchor name.
    hyphen(-), underscore(_), colon(:), period(.)
    name="anchor_name"
  • Anchor names must start in the alphabet.
    name="a001"
Link to a named anchor
  • Type the target URL, a number sign (#), and the name of the anchor.
    href="example.html#a001"

Example


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>

Output
Example pagenew window