什么是锚(anchor)

anchor的定义:

Definition:

An anchor is another word for internal link or bookmark on a web page. An anchor is a link that links within the same page of the document.

Alternate Definition of Anchor

Some designers use the term anchor to refer to any hyperlink on a web page. This definition stems from the fact that the HTML tag to create a link is the <a> tag or anchor tag.


internal links定义:

Definition:

An internal link is a link on a web page that links to another page on the same site or domain. Most internal links are used as navigation around the site or to provide additional information about a topic.

Alternate Definition of an Internal Link

Beyond being links to other pages on the same domain, internal links (often calledbookmarks or ) are also the links within one page. These links are usually found in tables of contents or as navigation within a long page. They allow designers to point to just the part of the page that is relevant.


<a>标签,anchor、link

A key feature of the web is the ability to connect (hyperlink or ‘link’) resources, including webpages, media files (images, video, etc.) and programs.

A hyperlink can be made from a document to:

  • a different resource      (source anchor)
    For example from a webpage to a Word document, or
  • a location within the current document   (destination anchor)
    For example from a menu at the top of the page to a point somewhere else on the same webpage.

Both the source and the destination of a link are referred to as anchors.


Source anchors

A source anchor is created in an HTML document (webpage) by adding an anchor element (<a>) with a hypertext reference (href) containing a uniform resource identifier (URI).

Using the code for a link to the Motive homepage as an example:

This glossary is compiled by <a href="http://www.motive.co.nz">Motive</a>.

<a href="http://www.motive.co.nz">Motive</a>.

         \_________URI_________/ 

   \_______href attribute_______/ 

\______________(source) anchor_____________/


Destination anchors

A destination anchor is often referred to by users as a ‘jump-to link’. In FrontPage it is called a ‘Bookmark’ and in Dreamweaver, it is a ‘Named anchor’.

To link to a point within a webpage, for example to link to content below the first fold, a destination anchor must be added.

A destination anchor is created by adding a fragment identifier, this is either:

  • an anchor element, with a name attribute, or
  • any other element, with an id attribute.
Hyperlink Element Destination anchor code Source anchor code
Page top <a> <a name="pagetop"></a> <a href="#pagetop"> Page top </a>
Content <a> <a name="content"></a> <a href="#content"> Content </a>
Destination anchors <h2> <h2 id="destination"> Destination anchors </h2> <a href="#destination"> Destination anchors </a>

ASSUMED #TOP ANCHOR

If creating an destination anchor to scroll to the top of the current page, be advised that some browsers [1] appear to ‘assume’ a #top anchor (not visible in the page source code). As implementation of this feature appears inconsistent, it is preferable to insert a #pagetopdestination anchor instead: <a name="pagetop" id="pagetop"></a>.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值