iframe Tag
The iframe
tag is used to display another web page within the current web page.
<iframe src="https://example.com" width="500" height="300"></iframe>
Using this code, the example.com
web page will be displayed within a 500x300 pixel area of the current page.
Main Attributes of the iframe Tag
src
-
The
src
attribute specifies the URL of the web page to embed. -
Code Example:
iframe src Attribute Example<iframe src="https://example.com"></iframe>
width
& height
-
The
width
andheight
attributes specify the size of theiframe
. -
Code Example:
iframe width & height Attributes Example<iframe src="https://example.com" width="400" height="250"></iframe>
frameborder
-
The
frameborder
attribute specifies whether or not to display a border around theiframe
. However, modern web browsers no longer recommend using this attribute, and it's advisable to use the CSSborder
property instead. -
Code Example:
iframe frameborder Attribute Example<!-- Deprecated Method --> <iframe src="https://example.com" frameborder="0"></iframe> <!-- Recommended Method --> <iframe src="https://example.com" style="border: none;"></iframe>
How to Use It?
The iframe
tag is commonly used to include videos (e.g., YouTube), maps (e.g., Google Maps), and external websites within a web page.
Lecture
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help