<iframe>


HTML <iframe> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head> 
<body>

<iframe src="//m.sbmmt.com">
  <p>您的浏览器不支持  iframe 标签。</p>
</iframe>

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

All major browsers support the <iframe> tag.


Tag definition and usage instructions

<iframe> tag specifies an inline frame.

An inline frame is used to embed another document within the current HTML document.


Tips and Notes

Tips:You can place the required text between <iframe> and </iframe>, so that Deals with browsers that don't support <iframe>.

Tip: Use CSS to define styles for <iframe> (including scroll bars).


Differences between HTML 4.01 and HTML5

HTML5 adds some new attributes and removes some attributes in HTML 4.01.


Differences between HTML and XHTML

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


Attribute

New: New attribute in HTML5.

marginheight##HTML5 Not supported. marginwidthpixelsHTML5 Not supported. namenamesandboxNew Allow-formsscrolling NoHTML5 is not supported. seamlessNewsrcURLsrcdocNewHTML_codewidthpixels
AttributesValueDescription
alignleft
right
top
middle
Bottom
HTML5 is not supported. HTML 4.01 is deprecated. Specifies how the <iframe> is aligned relative to surrounding elements.
frameborder1
0
HTML5 is not supported. Specifies whether to display the border around <iframe>.
heightpixelsSpecifies the height of <iframe>.
longdescURL##HTML5 Not supported. Specifies a page that contains a longer description of the <iframe>.
pixelsSpecifies the top and bottom margins of <iframe>.
Specifies the left and right margins of <iframe>.
Specifies the name of <iframe>.
"" Allow-same-origin
Allow-scripts
Allow-top-navigation

Defines a series of additional restrictions on the content of <iframe>.
yes auto

Specifies whether to display scroll bars in <iframe>.
seamlessSpecifies that <iframe> appears as part of the parent document.
Specifies the URL of the document to be displayed within an <iframe>.
Specifies that the HTML content in the page is displayed in <iframe> ; middle.
Specifies the width of <iframe>.

Global attributes

The<iframe> tag supports global attributes of HTML.

Event attributes

<iframe> tag supports HTML event attributes.

Related Articles

HTML Tutorial: HTML Framework

HTML DOM Reference Manual: IFrame Object