在< base>链接上使用空href是否可行?标签 [英] Is it OK to use empty href on links with <base> tag

查看:126
本文介绍了在< base>链接上使用空href是否可行?标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设定基本标记为:

I set the base tag as such:

<base href="http://mnapoli.github.com/PHP-DI/">

然后我想创建一个链接到 http://mnapoli.github.com/PHP-DI/ 以相对路径显示。

Then I would like to create a link to http://mnapoli.github.com/PHP-DI/ in relative path.

我试过:

I tried:

<a href="">link</a>

它可以在Chrome中使用,但是这种方法是标准的,应该适用于所有浏览器?

and it works in Chrome, but is this method standard and supposed to work on every browser?

推荐答案

尽管Mike的回答中提出的 href =./ (任何阅读代码的人都会更容易理解),所提出的问题的答案是使用空的URL是标准的,并且应该适用于所有浏览器。根据 STD 66 ,允许使用不含字符(空路径)的相对URL,并且关于相对URL的规则,它被解析为基本URL。

Although href="./" as suggested in Mike’s answer is better (easier to understand to anyone who reads the code), the answer to the question posed is that using an empty URL is standard and supposed to work on all browsers. According to STD 66, a relative URL with no characters (path-empty) is allowed, and by rules on relative URLs, it is resolved as the base URL.

这与文件夹或文件无关; URL是字符串,以及它们是否映射到服务器上的文件夹或文件由服务器决定。

This has nothing to do with folders or files; URLs are strings, and whether they get mapped to folders or files on a server is at the discretion of the server.

这篇关于在&lt; base&gt;链接上使用空href是否可行?标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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