HTML iframe
Created By: chatGPT
An iframe (inline frame) is an HTML element that allows you to embed another HTML page within the current page. It is commonly used to display content from other sources, such as videos, maps, or other web pages.
<iframe src="https://www.example.com" width="600" height="400" frameborder="0" allowfullscreen></iframe>
The src attribute specifies the URL of the page to embed. The width and height attributes control the size of the iframe, and frameborder can be set to 0 to remove the border around the iframe.
<iframe src="https://www.example.com" width="600" height="400" frameborder="0"></iframe>
To make an iframe responsive, you can use CSS to adjust its size relative to the parent container. A common approach is to set the width to 100% and to control the height with a fixed aspect ratio.
<style>
.responsive-iframe {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 Aspect Ratio */
}
.responsive-iframe iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class="responsive-iframe">
<iframe src="https://www.example.com" frameborder="0" allowfullscreen></iframe>
</div>
Make sure to consider the security aspect when using iframes, since they can expose your site to vulnerabilities such as clickjacking. You might want to include attributes like sandbox to add restrictions to the content within the iframe.
<iframe src="https://www.example.com" width="600" height="400" sandbox="allow-same-origin allow-scripts"></iframe>