HTML Hyperlink

本文深入探讨HTML中的<a>标签及其属性,包括href、target等,详细解释了如何创建邮件链接、理解不同链接状态,并介绍了如何在同页内及链接其他网页中的指定区域实现超链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

HTML Links - Hyperlinks

The HTML <a> tag defines a hyperlink that you can click on to jump to another document.

<a href="url">Link text</a>

Tip: The "Link text " doesn't have to be text. It  can be an image or any other HTML element

标签 <a> 的内容也可以是图片或者其他HTML元素


By default, links will appear as follows in all browsers: 

默认情况下在所有浏览器中,一个链接有以下几种状态:

  • An unvisited link is underlined and blue 未访问的链接,下划线,蓝色
  • A visited link is underlined and purple 已访问过的链接,下划线,紫色
  • An active link is underlined and red 活跃的(鼠标move over)指针,下划线,红色

The href Attribute

The most important attribute of the <a> element is the href attribute which specifies the destination of a link. 

属性 href 指定了一个超级链接的目的地.


创建一个 email 链接
<a href="mailto:xxx@yyy">

The target Attribute

The target attribute specifies where to open the linked document. 属性target指定在哪里打开所链接的文件。 

_blank Opens the linked document in a new window or tab (在新窗口或标签里打开)
_self Opens the linked document in the same frame as it was clicked (default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window (如果webpage被锁定在一个框架里,使用此属性值,则会 break out 这个frame, 如:全窗口显示被链接的文件)
framename Opens the linked document in a named frame
注意: Always add a trailing slash to subfolder references. 记得在子文件索引后加一个结尾斜杠。

If you link like this: href="http://blog.youkuaiyun.com/test", you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href="http://blog.youkuaiyun.com/test/".


The id Attribute

Used to create a bookmark inside an HTML document. 用于在HTML文件内创建书签

Create a link to the "Useful Tips Section" inside the same document 

同页内超链接跳转:

<a id="tips">Useful Tips Section</a>
<a href="#tips">Visit the Useful Tips Section</a>

链接其他网页中的指定区域:

<a href="http://blog.youkuaiyun.com/html_links.htm#tips">Visit the Useful Tips Section</a>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值