HTML iframe Element
Subject: html
πͺ HTML <iframe> Element
The <iframe> (short for inline frame) is used to embed another HTML document or external resource such as a webpage, video, map, or PDF within your current page. It acts like a window showing content from another location.
π§ Syntax
src: URL of the content to displaywidthandheight: Dimensions of the frametitle: Description for accessibility (required for screen readers)loading: Set tolazyfor performance optimizationallowfullscreen: Enables full-screen mode for media contentstyle: Internal CSS stylingframeborder: Deprecated (use CSS instead)
β Basic Iframe Example
π¨ Styled Iframe with Internal CSS
πΊ Embedding a YouTube Video
πΊοΈ Embedding a Google Map
π‘οΈ Security and Performance Tips
- Use 
sandboxattribute to restrict iframe actions: 
- Use 
loading="lazy"to defer off-screen content loading - Avoid mixed content (HTTP inside HTTPS pages)
 - Donβt embed content from untrusted sources
 
π Common Use Cases
- Embedding YouTube videos
 - Displaying Google Maps
 - Embedding PDFs or Slides
 - Loading another webpage
 
π§ Key Takeaways
<iframe>embeds external or internal pages into the current HTML document- Always include 
titlefor accessibility - Use 
sandbox,loading, and CSS for control, performance, and design - Use responsibly to avoid performance issues or security risks
 
Advertisement Slot 1
Advertisement Slot 2