html之链接

html之链接1 链接剖析 链接有两个主要的部分 目标和标签如连接到其他网页 在页面内跳转等功能目标通过 URL 编写 HTML 统一资源定位器 UniformResou URL 是一个网页地址

大家好,欢迎来到IT知识分享网。

1.链接剖析:
链接有两个主要的部分:目标和标签
如连接到其他网页,在页面内跳转等功能目标通过URL编写

HTML 统一资源定位器(Uniform Resource Locators)
URL 是一个网页地址。
URL可以由字母组成,如”runoob.com”,或互联网协议(IP)地址: 192.68.20.50。大多数人进入网站使用网站域名来访问,因为 名字比数字更容易记住。
URL – 统一资源定位器
Web浏览器通过URL从Web服务器请求页面。
当您点击 HTML 页面中的某个链接时,对应的 <a> 标签指向万维网上的一个地址。
一个统一资源定位器(URL) 用于定位万维网上的文档。
说明:






 scheme - 定义因特网服务的类型。最常见的类型是 http host - 定义域主机(http 的默认主机是 www) domain - 定义因特网域名,比如 runoob.com :port - 定义主机上的端口号(http 的默认端口号是 80) path - 定义服务器上的路径(如果省略,则文档必须位于网站的根目录中)。 filename - 定义文档/资源的名称 
Scheme 访问 用于
http 超文本传输协议 以 http:// 开头的普通网页。不加密。
https 安全超文本传输协议 安全网页,加密所有信息交换。
ftp 文件传输协议 用于将文件下载或上传至网站。
file 您计算机上的文件。

2.创建指向另一个页面的链接

输入<a href="page.html">其中page.html是目标网页的URL
输入标签文本,默认突出显示的文本
输入</a>结束对连接的定义

 <p> <a href="/index.html">标签文本</a> 是一个指向本网站中的一个页面的链接。</p> <p><a href="http://www.github.com/">标签文本</a> 是一个指向万维网上的页面的链接。</p> </body> </html>

标签文本 是一个指向本网站中的一个页面的链接。

标签文本 是一个指向万维网上的页面的链接。

html5允许块级链接,建议最好包含主要内容

HTML<a>rel 属性

HTML a 标签参考手册 HTML<a> 标签
实例

描述
alternate 文档的可选版本(例如打印页、翻译页或镜像)。
stylesheet 文档的外部样式表。
start 集合中的第一个文档。
next 集合中的下一个文档。
prev 集合中的前一个文档。
contents 文档目录。
index 文档索引。
glossary 文档中所用字词的术语表或解释。
copyright 包含版权信息的文档。
chapter 文档的章。
section 文档的节。
subsection 文档的子段。
appendix 文档附录。
help 帮助文档。
bookmark 相关文档。
nofollow Google 使用 “nofollow”,用于指定 Google 搜索引擎不要跟踪链接。
licence
tag
friend

在URL中应全部使用小写字母,不要让标签过长,

HTML<a> 属性

描述
_blank 在新窗口中打开被链接文档。
_self 默认。在相同的框架中打开被链接文档。
_parent 在父框架集中打开被链接文档。
_top 在整个窗口中打开被链接文档。
framename 在指定的框架中打开被链接文档。

4.连接到指定的锚
输入<a href="#anchor-name">
输入标签文本,突出显示的文本(通常默认显示为带下划线的蓝色)
输入</a>结束对链接的定义


如果锚位于另一个文档,<a href="page.html#anchor-name>(URL与#之间无空格) 如果有位于另一台服务器的页面,则需输入
<a href="http://www.site.com/path/page.html#anchor-name">

5.创建其他类型的链接
输入

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Creating Other Types of Links</title> </head> <body> <article> <h1>Other Types of Links</h1> <p>There are lots of different kinds of links that you can create on a Web page. More precisely, there are a lot of different files you can link to on your Web page.</p> <p>You can create links to directly to <a href="img/blueflax.jpg">a photo</a> or even make links out of photos.</p> <p>For example, here are Cookie and Woody again, except this time they are linked to other pages. <a href="cookie.html" title="All about Cookie"><img src="img/cookiefora.jpg" width="143" height="131" alt="Cookie" /></a> <a href="woody.html" title="All about Woody"><img src="img/woodygran.jpg" width="202" height="131" alt="Woody" /></a></p> <p>You can link directly to <a href="http://www.sarahsnotecards.com/catalunyalive/segadors.mov" rel="external">a video</a> file, too, though it's usually better to link to a page with the video embedded in it, such as with the <abbr title="Hypertext Markup Language revision 5">HTML5</abbr> <code>video</code> element.</p> <p>Although you can make a link to <a href="mailto:">someone's email address</a> with the mailto: protocol, I don't recommend it since spambots pick those up and then bombard them with spam. It's too bad because they are so convenient. If you activate the link, it opens your email program. It's probably better to offer your email address in a descriptive way, like &quot;someone at somedomain,&quot; although that isn't always foolproof either.</p> </article> </body> </html>

效果

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/121964.html

(0)
上一篇 2025-10-20 12:15
下一篇 2025-10-20 12:26

相关推荐

发表回复

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

关注微信