HTML iFrame
Welcome to the HTML <iframe>
tutorial on codeswithpankaj.com
. In this tutorial, we will explore what <iframe>
is, why it is used, its attributes, and provide examples to demonstrate its usage.
What is <iframe>
?
<iframe>
?An <iframe>
(short for inline frame) is an HTML element used to embed another document within the current HTML document. It allows you to display content from another web page, video, or interactive media seamlessly within your own web page.
Usage of <iframe>
<iframe>
Embedding External Content
You can use <iframe>
to embed content from external sources such as other websites, maps, videos, and more.
Example:
Displaying PDF Documents
You can embed PDF documents using <iframe>
.
Example:
Embedding Google Maps
Embedding Google Maps using <iframe>
.
Example:
Attributes of <iframe>
<iframe>
src
src
Specifies the URL of the content to be displayed in the <iframe>
.
width
and height
width
and height
Specifies the width and height of the <iframe>
in pixels or percentage.
frameborder
frameborder
Specifies whether to display a border around the <iframe>
.
allowfullscreen
allowfullscreen
Specifies whether the <iframe>
can be displayed in fullscreen mode.
sandbox
sandbox
Defines a sandboxing policy for the <iframe>
to restrict what the embedded content can do (e.g., restrict scripts, forms, etc.).
Styling <iframe>
<iframe>
You can style <iframe>
using CSS for better integration with your website's design.
Example:
Practical Examples
Here are some practical examples of how to use <iframe>
on your website.
Example 1: Embedding a YouTube Video
Example 2: Embedding a Google Map
Conclusion
HTML <iframe>
is a versatile element that allows you to embed external content seamlessly within your web page. Whether you're embedding videos, maps, or other web pages, <iframe>
provides a powerful way to enhance your website's functionality. Stay tuned to codeswithpankaj.com
for more tutorials and web development tips!
Last updated