HTML <frame> 标签
定义及使用说明
HTML5 不支持 <frame> 标签。
<frame> 标签定义 <frameset> 中的子窗口(框架)。
<frameset> 中的每个 <frame> 都可以设置不同的属性,比如 border、scrolling, noresize 等等。
注释:如果您希望验证包含框架的页面,请确保 <!DOCTYPE> 被设置为 "HTML Frameset DTD" 或者 "XHTML Frameset DTD" 。
浏览器支持
所有主流浏览器都支持 <frame> 标签。
HTML 4.01 与 HTML5之间的差异
HTML5 不支持 <frame> 标签,HTML 4.01 支持 <frame> 标签。
HTML 与 XHTML 之间的差异
在 HTML 中,<frame> 标签没有结束标签。在 XHTML 中,<frame> 标签必须被正确地关闭。
实例
简单的三框架页面:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML frame 标签 xinbiancheng.cn</title>
</head>
<frameset cols="25%,*,25%">
<frame src="../demo/frame_a.htm">
<frame src="../demo/frame_b.htm">
<frame src="../demo/frame_c.htm">
</frameset>
</html>
<frame> 标签可选的属性
属性 | 值 | 描述 |
---|---|---|
frameborder | 0 1 |
规定是否显示框架周围的边框。 HTML5 不支持。 |
longdesc | URL | 规定一个包含有关框架内容的长描述的页面。 HTML5 不支持。 |
marginheight | pixels | 定义框架的上方和下方的边距。 HTML5 不支持。 |
marginwidth | pixels | 定义框架的左侧和右侧的边距。 HTML5 不支持。 |
name | name | 规定框架的名称。 HTML5 不支持。 |
noresize | noresize | 规定无法调整框架的大小。 HTML5 不支持。 |
scrolling | yes no auto |
规定是否在框架中显示滚动条。 HTML5 不支持。 |
src | URL | 规定在框架中显示的文档的 URL。 HTML5 不支持。 |
标准属性
在 HTML 4.01 中,<frame> 标签支持如下标准属性:
属性 | 值 | 描述 |
---|---|---|
class | classname | 规定元素的类名 |
id | id | 规定元素的唯一 id |
style | style_definition | 规定元素的行内样式 |
title | text | 规定元素的额外信息 |
更多实例
例:如何使用三份不同的文档制作一个水平框架。
<!DOCTYPE html>
<html>
<frameset rows="25%,*,25%">
<frame src="../demo/frame_a.htm">
<frame src="../demo/frame_b.htm">
<frame src="../demo/frame_c.htm">
</frameset>
</html>
例:如何制作含有三份文档的框架结构,同时将他们混合置于行和列之中。
<!DOCTYPE html>
<html>
<frameset rows="50%,50%">
<frame src="../demo/frame_a.htm">
<frameset cols="25%,75%">
<frame src="../demo/frame_b.htm">
<frame src="../demo/frame_c.htm">
</frameset>
</frameset>
</html>
例:含noresize 属性的框架是不可调整尺寸的。在框架间的边框上拖动鼠标,您会发现边框是无法移动的。
<!DOCTYPE html>
<html>
<frameset cols="50%,*,25%">
<frame src="../demo/frame_a.htm" noresize="noresize">
<frame src="../demo/frame_b.htm">
<frame src="../demo/frame_c.htm">
</frameset>
</html>