iframe ... ⁄iframe
HTML5 iframe element
The iframe element represents a nested browsing context (document in document), an inline frame. »video
All browsing contexts, including the iframe, exemplified in this »video tutorial.
About iframe
- is an optional element
- multiple iframe elements allowed per HTML5 document
Display & support iframe
- display in browser »video
- display type:
inline-block by default
or
block if seamless attribute present





Parents, children iframe
- iframe nested within elements »iframe parents
- elements nested within iframe »iframe children
»examples
Attributes iframe
- required: none
- optional: specific attributes, global attributes, event attributes
Observation: if both src and srcdoc are present on iframe element, srcdoc ensures the content of the iframe , while src provides the fallback content. »video
src vs srcdoc
The difference between the src and srcdoc attributes. »video
Syntax iframe
1 | <> ... </> »video |
Attributes and Values iframe (comma separated)
< | attribute | = | "attribute_value(s)" | > | Video | Examples |
---|---|---|---|---|---|---|
1. specific attributes | ||||||
1. | width | = | pixels | »video | <width="200"> ... <⁄ > | |
2. | height | = | pixels | »video | <height="100"> ... <⁄ > | |
3. | name | = | a valid browsing-context name type text | »video | <name="some_name"> ... <⁄ > | |
4. | sandbox | = | "", , allow-forms, allow-pointer-lock, allow popups, allow-same-origin, allow-scripts, allow-top-navigation | »video | <sandbox> ... <⁄ > <sandbox="allow-forms"> ... <⁄ > | |
5. | seamless | = | "", , seamless | »video | <seamless> ... <⁄ > | |
6. | src | = | URL | »video | <src="http://any_site.com/file.php"> ... <⁄ > <src="folder/file.php"> ... <⁄ > <src="file_to_embed.php"> ... <⁄ > | |
7. | srcdoc | = | HTML elements | »video | <srcdoc="<!doctype html>..."> ... <⁄ > | |
8. | allowfullscreen | = | "", , allowfullscreen | - | <allowfullscreen> ... <⁄ > | |
All Specific Attributes | ||||||
2. global attributes | ||||||
1. | accesskey | = | keyboard key | »img | <accesskey="h"> ... </ > | |
2. | class | = | class name | »html »img | <class="class_name"> ... </ > | |
3. | contenteditable | = | "", , true, false | »html | <contenteditable="true"> ... </ > | |
4. | contextmenu | = | menu id value | »html | <contextmenu="menu_id_value"> ... </ > | |
5. | data-* | = | value | - | <data-http-error="404"> ... </ > | |
6. | dir | = | ltr, rtl, auto | »html | <dir="ltr"> ... </ > | |
7. | draggable | = | true, , false | »img | <draggable="false"> ... </ > | |
8. | dropzone | = | copy, move, link, string:, file: | - | <dropzone="copy"> ... </ > | |
9. | hidden | = | "", , hidden | »html »img | <hidden="hidden"> ... </ > | |
10. | id | = | id name | »html »img | <id="unique_id_name"> ... </ > | |
11. | itemid | = | URL | - | - | |
12. | itemprop | = | string | »link »a | - | |
13. | itemref | = | string | - | - | |
14. | itemscope | = | "", , itemscope | - | - | |
15. | itemtype | = | absolute URL | - | - | |
16. | lang | = | language code | »html »head»title »img | <lang="en"> ... </ > | |
17. | spellcheck | = | "", , true, false | »html | <spellcheck="true"> ... </ > | |
18. | style | = | CSS property:value | »html »img | <style="color:red"> ... </ > | |
19. | tabindex | = | integer | »img | <tabindex="3"> ... </ > | |
20. | title | = | text | »html »link»style »abbr»dfn »img »meter | <title="html page"> ... </ > | |
21. | translate | = | "", yes, no | »html »img | <translate="yes"> ... </ > | |
All Global Attributes | ||||||
3. global event attributes | ||||||
1. | onclick | = | script | » list | <element onclick="script" > ... | |
2. | ondblclick | = | script | » list | <element ondblclick="script" > ... | |
All Event Attributes |
Video demonstration iframe element
HTML5 iframe element: an inline frame
min | video details |
---|---|
00:00 | video tutorial: iframe element |
00:05 | iframe element represents a nested browsing-context (document in document) |
00:11 | the nested browsing context (iframe) inside the current browsing context (browser window) |
00:16 | iframe element allows you to embed a whole page (document) inside the current browser window |
00:40 | document in document: w3-video.com in inside.php |
00:55 | embedding another document, index2.php, within the current document index.php |
01:22 | iframe attributes allow for more actions: e.g. - seamless - makes the iframe look like part of the document - sandbox - for security reasons, - name- to target the iframe...and so forth |