是否有专用于为元素的所有后代设置基础 URL 的 HTML 属性?

Is there an HTML attribute dedicated to setting the base URL for all descendants of an element?

HTML 提供 base 元素作为指定文档中所有相关链接的基础 URL 的方法:

div,ol {margin:0;}
<!DOCTYPE html>
<html lang="en">
  <head>
    <base href="https://whosebug.com/questions/tagged/">
    <base target="_blank">
  </head>
  <body>
    <div>Web Development Tags at whosebug.com :</div>
    <ol>
      <li><a href="css">css</li>
      <li><a href="javascript">javascript</li>
      <li><a href="html">html</li>
    </ol>
  </body>
</html>

但是,照原样,每个文档只允许一个碱基 URL。

鉴于 HTML 的分层性质,我希望我能找到一个 HTML 属性,专门用于为一个元素的所有后代设置基础 URL。我找不到这个。

如果不存在这样的属性,我想它早就被提出了,我很想知道为什么它被拒绝了。这个我也没有找到。

据我所知,并在 w3schools

中陈述
  • 该标签指定文档中所有相关 URL 的基本 URL and/or 目标。
  • 标签必须有 href 或 target 属性,或两者都有。
  • 一个文档中只能有一个元素,而且必须在<head>元素内。

但是正如您提到的,此标签需要升级。也许数字 id 可以为特定的 URL 定义其他来源。我同意你的看法。

来自 by Alohci

It was indeed proposed a long time ago. At least once, in May 2007. And the xml:base attribute dates back at least as far as 1999. - Alohci, Oct 29, 2021 at 13:02