Menu Close

HTML 链接

一个网页可以包含各种链接,这些链接将您直接带到其他页面甚至给定页面的特定部分。 这些链接称为超链接。

超链接允许访问者通过单击单词、短语和图像在网站之间导航。 因此,您可以使用网页上可用的文本或图像创建超链接。

HTML使用标签 <a>来设置超文本链接。

超链接可以是一个字,一个词,或者一组词,也可以是一幅图像,您可以点击这些内容来跳转到新的文档或者当前文档中的某个部分。

当您把鼠标指针移动到网页中的某个链接上时,箭头会变为一只小手。

在标签<a> 中使用了href属性来描述链接的地址。

默认情况下,链接将以以下形式出现在浏览器中:

  • 一个未访问过的链接显示为蓝色字体并带有下划线。
  • 访问过的链接显示为紫色并带有下划线。
  • 点击链接时,链接显示为红色并带有下划线。

注意:如果为这些超链接设置了 CSS 样式,展示样式会根据 CSS 的设定而显示。

<a href = "Document URL" ... attributes-list>Link Text</a>
<!DOCTYPE html>
<html>
   
   <head>
      <title>Hyperlink Example</title>
   </head>
    
   <body>
      <p>Click following link</p>
      <a href = "https://2743.com" target = "_self">爱芯网</a>
   </body>
    
</html>

结果显示

Click following link

爱芯网

 target <target>属性

使用 target 属性,你可以定义被链接的文档在何处显示。

Sr.No Option & Description
1 _blank

Opens the linked document in a new window or tab. 在新窗口中打开被链接文档。

2 _self

Opens the linked document in the same frame. 在被点击时的同一框架中打开被链接文档(默认)。

3 _parent

Opens the linked document in the parent frame. 在父框架中打开被链接文档。

4 _top

Opens the linked document in the full body of the window. 在窗口主体中打开被链接文档。

5 targetframe

Opens the linked document in a named targetframe.

除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Leave the field below empty!

Posted in HTML 教程

Related Posts