html anchor (mao dian) - special hyperlinks

Anchor (anchor): in fact hyperlinks one of a special kind of hyperlink

Ordinary hyperlink, <a href="路径"> </a> is jump to different pages

The anchor, <a href="路径"> </a> can jump between different pages in the same location

     You can see, jump to a hyperlink anchor with ordinary hyperlink format is the same,

Step 1. anchor:

1.1. To establish an anchor target,

As mentioned above, the anchor can jump between different location on the same page, in fact, to jump between elements,

The scenario is common, very long page, allowing users to easily jump between different parts of the page

        Establish anchor target, just give the target element id or name to increase recommended id:

   1.2. To create a jump to the anchor div id = "test", and

   Note: 1. The anchor of a hyperlink path must include "#", and the id or name followed by the elements

              (So ​​id and name must be the same, in fact, I tried sometimes name is not in effect)

2. Use anchor Summary:

2.1 Establish an anchor element must have a name or id attribute, two are the best

  2.2. Anchor hyperlink must contain a pound sign "#" anchor hyperlinks are linked very end, specific examples look back

2.3. The same page written in different parts of the jump, anchors

The target element: <the p-the above mentioned id = "the Test"> </ the p->  anchor hyperlink: <a href="#test"> </a>

  2.4 Different page jumps, while there is an anchor

The target element: a.html page <div id = "test" / >  anchor hyperlink: <a href="a.html#test"> </a>

(A.html jump to the page, and then look for a test element id =)

  2.5. Different parameters Page jump, while the presence of the anchor

The target element: ? = Abc a.php the p-pages <div id = "test" / >  anchor hyperlink: <a href="a.php?p=abc#test"> </a>

Reproduced in: https: //www.jianshu.com/p/25a7adf594e8

Guess you like

Origin blog.csdn.net/weixin_33728268/article/details/91088955