HTML Iframes.
An iframe (Inline Frame) is used to display a web page within another web page. it is commonly used for maps, videos, and ads.
The Essentials
The <iframe> tag defines the inline frame.
The 'src' attribute specifies the URL of the page to embed.
The 'width' and 'height' attributes define the size.
The 'title' attribute is required for screen readers to describe the content.
The 'loading="lazy"' attribute improves performance by loading the iframe only when visible.
Iframes have their own browsing history and window object.
Professional Insights
The 'sandbox' Attribute
Removing Borders
Responsive Iframes
Embedding YouTube and Google Maps
Critical Pitfalls
Missing the 'title' attribute, which is a major accessibility violation.
Embedding sites that have 'X-Frame-Options' set to 'DENY'—the iframe will appear blank.
Not using 'sandbox' for third-party widgets, which can be a security risk.
Forgetting to set a height, causing the iframe to be too small to read.