This <iframe> element creates a frame that can be placed anywhere inside a document.
Unlike the <frame>
element, it is inserted into a normal
HTML page that has a <body>
tag.
<iframe> |
Yes | Yes | Yes | Yes | Yes |
There are some new attributes for HTML5, and several HTML 4.01 attributes are deprecated in HTML5.
Attribute | Value | Description |
---|---|---|
align | left right top middle bottom |
Not supported in HTML5. Set the alignment |
frameborder | 1 0 |
Not supported in HTML5. Set whether or not to display a border |
height | pixels | Set the height |
longdesc | URL | Not supported in HTML5. Set URL for a long description for the content |
marginheight | pixels | Not supported in HTML5. Set the top and bottom margins |
marginwidth | pixels | Not supported in HTML5. Set the left and right margins |
name | text | Set the name for iframe |
sandbox | "" allow-forms allow-same-origin allow-scripts allow-top-navigation |
Enables extra restrictions for iframe |
scrolling | yes no auto |
Not supported in HTML5. whether to display scrollbars for iframe |
seamless | seamless | Set to seamless melt-in with containing document |
src | URL | Set the address URL for the document to embed in the iframe |
srcdoc | HTML_code | Set the HTML content to show in the iframe |
width | pixels | Set the width |
The <iframe> tag supports the Global Attributes in HTML.
The <iframe> tag supports the Event Attributes in HTML.
iframe:focus { outline: none; } iframe[seamless] { display: block; }
A demo showing how to use <iframe> tag
<html>
<body>
<p>
<iframe id="myIframe"
frameborder="1"
scrolling="yes"
src="http://java2s.com"
width="600"
height="400">
</iframe>
</p><!-- w w w.j a v a 2s . c o m-->
</body>
</html>