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 |
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>