当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <base>标签
The base element specifies a base URL for all the links in a page.
使用base元素为页面所有的连接指定一个基础的URL
In HTML the <base> tag has no end tag.
在HTML中<base>标签不需要结束标签
In XHTML the <base> tag must be properly closed.
在XHTML中<base>标签必须合理关闭
Note: The <base> tag must go inside the head element.
注意:<base>标签必须使用在head元素内
Assume that the absolute address for an image is:
假设有一个图片的绝对地址:
<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" /> |
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 |
属性 | 值 | 描述 | 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 |
NONE
无
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