Latest web development tutorials

HTML <iframe> tag

Examples

Mark an inline frame:

<iframe src="http://www.w3big.com"></iframe>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the <iframe> tag.


Tag definitions and instructions

<Iframe> tag specified an inline frame.

An inline frame is used in the current HTML document embedded in another document.


Tips and Notes

Tip: You can put the text needs to be placed in the <iframe> and </ iframe> between, so that you can cope without support <iframe> browser.

Tip: Use CSS for the <iframe> (including the scroll bar) define the style.


Differences between HTML 4.01 and HTML5

HTML5 adds some new properties, and removed some HTML 4.01 attributes.


Differences between HTML and XHTML

In XHTML, name attribute is deprecated and will be removed. Please use the id attribute instead.


Attributes

New: HTML5 new property.

属性 描述
align left
right
top
middle
bottom
HTML5 不支持。HTML 4.01 已废弃。 规定如何根据周围的元素来对齐 <iframe>。
frameborder 1
0
HTML5 不支持。规定是否显示 <iframe> 周围的边框。
height pixels 规定 <iframe> 的高度。
longdesc URL HTML5 不支持。规定一个页面,该页面包含了有关 <iframe> 的较长描述。
marginheight pixels HTML5 不支持。规定 <iframe> 的顶部和底部的边距。
marginwidth pixels HTML5 不支持。规定 <iframe> 的左侧和右侧的边距。
name name 规定 <iframe> 的名称。
sandbox New ""
allow-forms
allow-same-origin
allow-scripts
allow-top-navigation
对 <iframe> 的内容定义一系列额外的限制。
scrolling yes
no
auto
HTML5 不支持。规定是否在 <iframe> 中显示滚动条。
seamless New seamless 规定 <iframe> 看起来像是父文档中的一部分。
src URL 规定在 <iframe> 中显示的文档的 URL。
srcdoc New HTML_code 规定页面中的 HTML 内容显示在 <iframe> 中。
width pixels 规定 <iframe> 的宽度。


Global Properties

<iframe> tag supports HTML global properties .


Event Properties

<iframe> tag supports HTML event properties .


related articles

HTML Tutorial: HTML frame

HTML DOM Reference Manual: the IFrame objects