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