HTML中的绝对链接和相对链接 [英] Absolute vs relative links in HTML

查看:120
本文介绍了HTML中的绝对链接和相对链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找HTML中绝对链接和相对链接的完整权威解释.

I have been looking for a complete definitive explanation of absolute vs relative links in HTML.

  1. <a href="http://www.example.com/page.html">link page</a>
  2. <a href="//page2.html">link page</a>
  3. <a href="/page3.html">link page</a>
  4. <a href="./page4.html">link page</a>
  5. <a href="../page5.html">link page</a>
  1. <a href="http://www.example.com/page.html">link page</a>
  2. <a href="//page2.html">link page</a>
  3. <a href="/page3.html">link page</a>
  4. <a href="./page4.html">link page</a>
  5. <a href="../page5.html">link page</a>

所以在上面的列表中,

  1. 是绝对链接
  2. 相对于使用http或https的网站根目录
  3. 相对于网站根目录?
  4. 在当前目录中吗?
  5. 在目录中吗?

推荐答案

这不是HTML.这是操作系统各个方面的绝对路径或相对路径.

This is not HTML. This is absolute or relative paths in all aspects of a operating system.

  1. 是的,没有解释.是没有SSL(https)的链接
  2. 是的.如果用户使用http访问网络,它将自动切换为http;如果用户使用https访问网络,则将自动切换为https.
  3. 是的.它链接到//domain/thelink.ext
  4. 是的.与在操作系统中一样,./是当前目录.很多时候,您必须指定此项以确保它是最新的.
  5. 是的.与在操作系统中一样,../更改为父目录.您可以进行嵌套,../../../表示最多3个父目录.
  1. Yes, there's no interpretation. Is a link without SSL (https)
  2. Yes. It switches automatically to http if user visit the web in http, and https if user visit the web in https.
  3. Yes. It links to the //domain/thelink.ext
  4. Yes. As in a operating system, ./ is the current directory. Many times you must to specify this to ensure is the current.
  5. Yes. As in a operating system, ../ changes to parent directory. You can make nesting and ../../../ will mean that up 3 parent directories.

这篇关于HTML中的绝对链接和相对链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆