当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <base>标签

HTML
HTML 介绍
HTML 元素
HTML 基本标签
HTML 格式
HTML 实体字符
HTML 链接
HTML 框架
HTML 表格
HTML 列表
HTML 表单
HTML 图片
HTML 背景
HTML 颜色
HTML 颜色值
HTML 颜色名
HTML 便条
HTML 布局
HTML 字体
HTML 4.0
HTML 样式

HTML <base>标签


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 319 ::
收藏到网摘: n/a

Definition and Usage
用法

The base element specifies a base URL for all the links in a page.
使用base元素为页面所有的连接指定一个基础的URL


Differences Between HTML and XHTML
在HTML和XHTML中的区别

In HTML the <base> tag has no end tag.
在HTML中<base>标签不需要结束标签

In XHTML the <base> tag must be properly closed.
在XHTML中<base>标签必须合理关闭


Tips and Notes
注意点

Note: The <base> tag must go inside the head element.
注意:<base>标签必须使用在head元素内


Example
实例

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" />


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属性就无效了
  • _blank - all the links will open in new windows
    所有的连接将在新窗口打开
  • _self - all the links will open in the same frame they where clicked
    所有的连接将在自身窗口或是框架中打开
  • _parent - all the links will open in the parent frameset
    所有连接在父级框架集中打开
  • _top - all the links will open in the full body of the window
    所有连接在窗口的主体中打开
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

评论 (0) All

登陆 | 还没注册?