如何在HTML中创建指向另一个文档的超链接?


使用<a>标签创建超链接。HTML <a>标签用于创建指向另一个文档或当前文档中某个位置的超链接。

以下是属性:

属性

描述
Charset
字符编码
定义链接文档的字符编码。
Coords
如果 shape = "rect",则 coords = "left, top, right, bottom"

如果 shape = "circ",则 coords = "centerx,centery,radius"

如果 shape = "poly",则 coords = "x1, y1, x2, y2,..,xn,yn"
指定适合shape属性的坐标,以定义图像地图中图像的区域。
download
文件名

当用户点击超链接时,这将下载目标。
Href
URL
指定链接指向的页面的URL或锚点的名称。
Hreflang
语言代码
目标URL的语言代码。
media
媒体查询
它指定链接文档针对哪个媒体进行了优化。
Name
章节名称
标记页面中链接跳转到的区域。
Rel
alternate
指定
 stylesheet
 start
 next
 prev
contents
index
glossary
copyright
chapter
section
subsection
appendix
 help
bookmark
描述当前文档和目标URI之间的关系。
Rev
alternate
指定
stylesheet
start
 next
prev
 contents
index
 glossary
copyright
chapter
section
subsection
appendix
 help
bookmark
指定目标URL和当前文档之间的关系。
Shape
rect
矩形
circ
 圆形
 poly
 多边形
在何处打开目标URL。
_blank - 目标URL将在新窗口中打开。
_self - 目标URL将在单击它的同一框架中打开。
_parent - 目标URL将在父框架集中打开。
_top - 目标URL将在窗口的整个主体中打开。
type
mime_type
指定目标URL的MIME(多用途互联网邮件扩展)类型。

示例

您可以尝试运行以下代码来创建链接:

<!DOCTYPE html>
<html>
   <head>
      <title>HTML a Tag</title>
   </head>
   <body>
      <p>This is a link to <a href = "https://qries.com">Qries.com</a></p>
   </body>
</html>

更新于:2020年3月3日

2K+ 浏览量

启动您的职业生涯

完成课程获得认证

开始学习
广告
© . All rights reserved.