0% completed
In this lesson, you'll learn about the <iframe>
element, which is used to embed another HTML page or external content (like videos or maps) within your current webpage. Iframes allow you to display content from another source without leaving your site.
An iframe (short for inline frame) lets you embed another HTML document inside the current document. This can be used to show content such as a video player, an interactive map, or even an entirely separate website within a section of your page.
The basic structure of an iframe is very simple:
<iframe src="URL"></iframe>
<iframe>
: The element used to embed another document.src="URL"
: Specifies the URL of the page or content you want to display.You can also include additional attributes such as width
, height
, and frameborder
to control how the iframe is displayed.
Here are some of the most commonly used attributes with iframes:
src
The URL of the page to embed.width
and height
Define the dimensions of the iframe in pixels.frameborder
Specifies whether the iframe should have a border. (Typically set to "0"
to remove the border.)allowfullscreen
Allows the embedded content to be viewed in full-screen mode.This example demonstrates a simple iframe that embeds an external webpage.
Explanation:
src="https://www.example.com"
: Embeds the content from example.com.width="600" height="400"
: Sets the iframe size to 600 pixels wide by 400 pixels tall.frameborder="0"
: Removes any visible border around the iframe.Often, iframes are used to embed video players (such as YouTube videos) into a webpage.
Explanation:
src
attribute contains the YouTube embed URL.frameborder="0"
removes the border.allowfullscreen
enables full-screen viewing of the video.<iframe>
and </iframe>
) is a good practice.Understanding how to use iframes allows you to integrate external content into your websites, making them more dynamic and engaging. In the next lesson, we'll cover HTML – Details & Summary for Collapsible Content, which introduces interactive sections that users can expand or collapse.
.....
.....
.....