html

梗概:

<base>标签指定网页内部的所有相对 URL 的计算基准

  1. 整张网页只能有一个<base>标签
  2. 只能放在<head>里面。
  3. 它是单独使用的标签,没有闭合标签

注意:

  1. <base>标签必须至少具有href属性或target属性之一。
  2. 尤其需要注意锚点,这时锚点也是针对<base>计算的,而不是针对当前网页的 URL。

实例:

<head>
<base href="https://www.example.com/files/" target="_blank">
</head>

<base>标签的href属性给出计算的基准网址,target属性给出如何打开链接的说明(参见《链接》一章)。 已知计算基准是https://www.example.com/files/,那么相对 URL foo.html,就可以转成绝对 URL https://www.example.com/files/foo.html