Publish in HTML Tutorial el 24/05/2025 15:43
The HTML <iframe>
(Inline Frame) element embeds another HTML page within the current document. It creates a nested browsing context, essentially allowing you to display a webpage within a webpage. IFrames are commonly used for embedding videos, maps, advertisements, or other external content while keeping it isolated from your main page.
Here's the basic structure of an iframe:
This example shows how to embed a Google Maps location:
Embedding a YouTube video with responsive sizing:
This example shows a sandboxed iframe with restricted permissions:
Changing iframe content dynamically with JavaScript:
Basic communication between parent window and iframe using postMessage:
title
attribute for accessibilityloading="lazy"
for better performance on offscreen iframessrcdoc
attribute for inline HTML contentpadding-bottom
techniqueIFrames can pose security risks if not properly configured:
sandbox
attribute to restrict capabilitiesX-Frame-Options
header on your own pages to prevent clickjackingIFrames can significantly impact page performance:
The <style> HTML element contains style information for a document, or part of a document. ...
The <strong> element is used to indicate that its content has strong importance, seriousnes...
The <span> element is an inline container used to mark up a part of a text or document. Unl...
The <source> element is used to specify multiple media resources for media elements like &l...
The <small> element is used to represent side-comments and small print, typically for discl...
HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...