什么是链接?
它是从一个网络资源到另一个网络资源的连接。链接有两个端点,一个锚点和一个方向。链接从“源”锚点开始,指向“目标”锚点,它可以是任何 Web 资源,例如图像、视频剪辑、声音片段、程序、HTML 文档或 HTML 文档中的元素.
HTML 链接语法
使用“a”标签在 HTML 中指定链接。
语法说明:
href : The href attribute is used to specify
the destination address of the link used.
Text link : The text link
is the visible part of the link.
输入 :
html
Example Of Adding a link
Click on the following link
GeeksforGeeks
html
Internal Link And External Link Example
GeeksforGeeks Contribute
It is a link to the contribute page on GeeksforGeeks' website.
GeeksforGeeks
It is a link to the GeeksforGeeks website on the World Wide Web.
html
Changing the default colors of links
Visited Link
GeeksforGeeks
Link
facebook
hovering effect
GeeksforGeeks
html
Various options available in the Target Attribute
If you set the target attribute to "_blank",
the link will open in a new browser window or tab.
GeeksforGeeks
If you set the target attribute to "_self",
the link will open in the same window or tab.
GeeksforGeeks
If you set the target attribute to "_top",
the link will open in the full body of the window.
GeeksforGeeks
If you set the target attribute to "_parent",
the link will open in the parent frame.
GeeksforGeeks
html
html
Topic 1
paragraph 1
.....
Topic 2
paragraph 1
.....
Topic 3
paragraph 1
.....
Topic 4
paragraph 1
.....
Topic 5
paragraph 1
.....
Topic 6
paragraph 1
.....
Topic 7
paragraph 1
.....
Topic 8
paragraph 1
.....
Topic 9
paragraph 1
.....
Topic 10
paragraph 1
.....
Topic 11
paragraph 1
.....
Topic 12
paragraph 1
.....
Topic 13
paragraph 1
.....
Topic 14
paragraph 1
.....
Topic 15
paragraph 1
.....
Topic 16
paragraph 1
.....
Topic 17
paragraph 1
.....
Topic 18
paragraph 1
.....
Topic 19
paragraph 1
.....
Topic 20
paragraph 1
.....
html
Creating a download link
Download PDF File
输出 :
内部链接
内部链接是一种超链接,其目标或目的地是同一网站或域上的资源,例如图像或文档。
输入:
html
Internal Link And External Link Example
GeeksforGeeks Contribute
It is a link to the contribute page on GeeksforGeeks' website.
GeeksforGeeks
It is a link to the GeeksforGeeks website on the World Wide Web.
输出 :
更改 HTML 中的链接颜色
不同类型的链接以不同的格式出现,例如:
- 默认情况下,未访问的链接带有下划线和蓝色。
- 默认情况下,访问过的链接带有下划线和紫色。
- 默认情况下,活动链接带有下划线和红色。
可以使用 CSS 更改链接的外观。
输入 :
html
Changing the default colors of links
Visited Link
GeeksforGeeks
Link
facebook
hovering effect
GeeksforGeeks
输出:
链接中的目标属性
target 属性用于指定打开链接文档的位置。 target 属性中可以使用的各种选项在下表中列出:
输入:
html
Various options available in the Target Attribute
If you set the target attribute to "_blank",
the link will open in a new browser window or tab.
GeeksforGeeks
If you set the target attribute to "_self",
the link will open in the same window or tab.
GeeksforGeeks
If you set the target attribute to "_top",
the link will open in the full body of the window.
GeeksforGeeks
If you set the target attribute to "_parent",
the link will open in the parent frame.
GeeksforGeeks
输出:
在 HTML 中使用图像作为链接
图像可用于创建指向指定 url 的链接。
输入:
输出:
为网页创建书签链接
书签是一个链接,可以用来跳转到网页的指定部分。如果网页很长,书签就非常有用。
创建书签的步骤是:
1. 使用 id 属性,创建书签。
2. 将网页的指定部分添加到书签中。
输入 :
html
Topic 1
paragraph 1
.....
Topic 2
paragraph 1
.....
Topic 3
paragraph 1
.....
Topic 4
paragraph 1
.....
Topic 5
paragraph 1
.....
Topic 6
paragraph 1
.....
Topic 7
paragraph 1
.....
Topic 8
paragraph 1
.....
Topic 9
paragraph 1
.....
Topic 10
paragraph 1
.....
Topic 11
paragraph 1
.....
Topic 12
paragraph 1
.....
Topic 13
paragraph 1
.....
Topic 14
paragraph 1
.....
Topic 15
paragraph 1
.....
Topic 16
paragraph 1
.....
Topic 17
paragraph 1
.....
Topic 18
paragraph 1
.....
Topic 19
paragraph 1
.....
Topic 20
paragraph 1
.....
输出:
在 HTML 中创建下载链接
可以创建 pdf、doc 或 zip 文件的文本链接以使其可下载。
输入 :
html
Creating a download link
Download PDF File
输出: :
支持的浏览器:
- 谷歌浏览器
- 微软边缘
- 火狐
- 歌剧
- 苹果浏览器