HTML <base>标签
|
<img src="http://www.w3schools.com/images/smile.gif" /> |
Now we insert the <base> tag, which specifies a base URL for all of the links in a page, in the head section of a page:
现在我们插入<base>标签,就可以为页面内的所有连接加上基础URL:
<head> <base href="http://www.w3schools.com/images/" /> </head> |
When inserting images on the page in the example above, we just have to specify the relative address, and the browser will look for that file using the full URL, "http://www.w3schools.com/images/smile.gif":
加上之后我们只需要指定相对的地址就可以将URL变为"http://www.w3schools.com/images/smile.gif":
<img src="smile.gif" /> |
Required Attributes
必要属性
DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
下表中的DTD列指明了被支持的DTD属性。S=Strict(精确的),T=Transitional(传统的),F=Frameset(框架)
属性 | 值 | 描述 | DTD |
---|---|---|---|
href | URL | Specifies the URL to use as the base URL for links in the page 为页面的所有连接指定基础URL | STF |
Optional Attributes
可选属性
属性 | 值 | 描述 | DTD |
---|---|---|---|
target | _blank _parent _self _top | Where to open all the links on the page. This attribute can be overridden by using the target attribute in each link. 页面中所有连接的打开方式。如果每个连接使用了target属性那么base的target属性就无效了
| TF |
Standard Attributes and Events
标准属性以及事件
NONE
无
Try-It-Yourself Demos
演示
One target for all links
How to use the <base> tag to let all the links on a page have the same target.
怎样使用<base>标签来让所有连接使用同一个target