HTML Iframes

HTML <iframe>

The <iframe> element is used to embed another HTML page or content (like a website, video, or map) inside the current webpage. It creates an inline frame for displaying external resources.


Basic Syntax


 

  • src → URL of the page to embed

  • width → Width of the iframe

  • height → Height of the iframe


Example 1: Embedding a Website


 

Output:
Displays the content of example.com within your page.


Example 2: Embedding a YouTube Video


 

Output:
Shows the YouTube video inside your page.


Key Attributes

Attribute Purpose
src URL of the embedded content
width Width of iframe
height Height of iframe
frameborder Border around iframe (0 = none)
allowfullscreen Allows full-screen playback
title Provides accessibility text

Notes

  • <iframe> can display external or internal pages.

  • Be cautious: Some websites block embedding for security.

  • Use CSS to style and position iframes properly.


<iframe> is widely used for videos, maps, and embedding external content within webpages.

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *