HTML中的绝对链接和相对链接 [英] Absolute vs relative links in HTML
本文介绍了HTML中的绝对链接和相对链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找HTML中绝对链接和相对链接的完整权威解释.
I have been looking for a complete definitive explanation of absolute vs relative links in HTML.
-
<a href="http://www.example.com/page.html">link page</a>
-
<a href="//page2.html">link page</a>
-
<a href="/page3.html">link page</a>
-
<a href="./page4.html">link page</a>
-
<a href="../page5.html">link page</a>
<a href="http://www.example.com/page.html">link page</a>
<a href="//page2.html">link page</a>
<a href="/page3.html">link page</a>
<a href="./page4.html">link page</a>
<a href="../page5.html">link page</a>
所以在上面的列表中,
- 是绝对链接
- 相对于使用http或https的网站根目录
- 相对于网站根目录?
- 在当前目录中吗?
- 在目录中吗?
推荐答案
这不是HTML.这是操作系统各个方面的绝对路径或相对路径.
This is not HTML. This is absolute or relative paths in all aspects of a operating system.
- 是的,没有解释.是没有SSL(https)的链接
- 是的.如果用户使用http访问网络,它将自动切换为http;如果用户使用https访问网络,则将自动切换为https.
- 是的.它链接到
//domain/thelink.ext
- 是的.与在操作系统中一样,
./
是当前目录.很多时候,您必须指定此项以确保它是最新的. - 是的.与在操作系统中一样,
../
更改为父目录.您可以进行嵌套,../../../
表示最多3个父目录.
- Yes, there's no interpretation. Is a link without SSL (https)
- Yes. It switches automatically to http if user visit the web in http, and https if user visit the web in https.
- Yes. It links to the
//domain/thelink.ext
- Yes. As in a operating system,
./
is the current directory. Many times you must to specify this to ensure is the current. - Yes. As in a operating system,
../
changes to parent directory. You can make nesting and../../../
will mean that up 3 parent directories.
这篇关于HTML中的绝对链接和相对链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文