HTML <a> 标签

实例

指向 w3school 的超链接:

<a href="http://www.w3school.com.cn">W3School</a>

定义和用法

<a> 标签定义超链接,用于从一张页面链接到另一张页面。

<a> 元素最重要的属性是 href 属性,它指示链接的目标。

在所有浏览器中,链接的默认外观是:

  • 未被访问的链接带有下划线而且是蓝色的
  • 已被访问的链接带有下划线而且是紫色的
  • 活动链接带有下划线而且是红色的

提示和注释

提示:如果不使用 href 属性,则不可以使用如下属性:download, hreflang, media, rel, target 以及 type 属性。

提示:被链接页面通常显示在当前浏览器窗口中,除非您规定了另一个目标(target 属性)。

提示:请使用 CSS 来设置链接的样式。

属性

New : HTML5 中的新属性。

属性描述
charset char_encoding HTML5 中不支持。规定被链接文档的字符集。
coords coordinates HTML5 中不支持。规定链接的坐标。
download filename 规定被下载的超链接目标。
href URL 规定链接指向的页面的 URL。
hreflang language_code 规定被链接文档的语言。
media media_query 规定被链接文档是为何种媒介/设备优化的。
name section_name HTML5 中不支持。规定锚的名称。
rel text 规定当前文档与被链接文档之间的关系。
rev text HTML5 中不支持。规定被链接文档与当前文档之间的关系。
shape
  • default
  • rect
  • circle
  • poly
HTML5 中不支持。规定链接的形状。
target
  • _blank
  • _parent
  • _self
  • _top
  • framename
规定在何处打开链接文档。
type MIME type

规定被链接文档的的 MIME 类型。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


代码部分

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>a标签</title>
        <body>
<div style="border:1px solid red">
            <p>frame name:view_frame</p>
            <div style="border:1px solid red">
    <iframe style=" width: 100%; height: 400px; " name="view_frame" src="" frameborder="no" scrolling="auto"></iframe>
</div>
</div>
<a href="https://www.cnblogs.com/orzjiangxiaoyu/" target="view_frame">在框架中打开</a>
<textarea style="width:100%"><a href="https://www.cnblogs.com/orzjiangxiaoyu/" target="view_frame"></textarea>
<a href="https://www.cnblogs.com/orzjiangxiaoyu/" target="_blank">在新窗口打开</a>
<textarea style="width:100%"><a href="https://www.cnblogs.com/orzjiangxiaoyu/" target="view_frame"></textarea>
<a href="#a">跳到第十一段</a>
<textarea style="width:100%"><a href="#a">跳到第十一段</a>...<a name="a"><p>第十一段</p></a></textarea>
<p>第一段</p>
<p>第二段</p>
<p>第三段</p>
<p>第四段</p>
<p>第五段</p>
<p>第六段</p>
<p>第七段</p>
<p>第八段</p>
<p>第九段</p>
<p>第十段</p>
<a name="a"><p>第十一段</p></a>
            </body>
        </head>
    </html>

 

展示窗口

 
posted @ 2020-04-07 20:05  orz江小鱼  阅读(89)  评论(0编辑  收藏  举报