HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tutorial

HTML Basics

Introduction to HTMLHTML EditorsHTML StructureHTML Elements & AttributesHTML HeadingsHTML ParagraphsHTML FormattingHTML CommentsHTML Styles

HTML Text and Links

HTML Text FormattingHTML Quotations & CitationsHTML LinksHTML Email Links

HTML Lists and Tables

HTML ListsHTML TablesTable Styling & Borders

HTML Images and Media

HTML ImagesHTML Picture ElementHTML AudioHTML VideoHTML Embed & Object

HTML Forms

HTML Forms OverviewHTML Form ElementsHTML Input TypesHTML Input AttributesHTML Form AttributesHTML Form Validation

HTML Layout

HTML Block vs Inline ElementsHTML Div & SpanHTML Semantic Layout TagsHTML Iframes

Advanced HTML

HTML Entities & SymbolsHTML EmojisHTML Head Element TagsHTML Meta Tags for SEOHTML Responsive Design

HTML References

HTML5 New TagsDeprecated TagsHTML Global AttributesEvent AttributesComplete HTML Tag ListComplete HTML5 ElementsHTML Tutorial PDF
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML Iframes

HTML Layout

HTML Iframes

An iframe (short for inline frame) is an HTML element that allows you to embed another webpage or document inside the current webpage. It acts like a window or a mini browser within your page.

Iframe Syntax

html

<iframe src="https://www.example.com" title="Iframe Example"></iframe>

Iframe Attributes:

  • src – The URL of the page to embed.
  • title – Provides a text description (important for accessibility).

Iframe Attributes Explained

AttributeDescriptionExample
srcSpecifies the URL of the page to embed.<iframe src="https://example.com"></iframe>
heightSets the height of the iframe.<iframe src="page.html" height="400"></iframe>
widthSets the width of the iframe.<iframe src="page.html" width="600"></iframe>
titleProvides a title for accessibility.<iframe src="page.html" title="Demo"></iframe>
nameUsed to name the iframe (useful for targeting links).<iframe name="myFrame"></iframe>
sandboxAdds security restrictions (disables scripts, forms, etc.).<iframe src="page.html" sandbox></iframe>
allowfullscreenAllows the iframe to display full-screen content.<iframe src="video.html" allowfullscreen></iframe>
loadingControls loading behavior (lazy or eager).<iframe src="page.html" loading="lazy"></iframe>
referrerpolicyControls the referrer information sent when loading content.<iframe src="page.html" referrerpolicy="no-referrer"></iframe>

Example: Embedding a Website

html

<iframe src="https://www.html5andcss3.org" width="800" height="400" title="HTML5 & CSS3"></iframe>

Example: Embedding a YouTube Video

html

<iframe width="560" height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
title="YouTube video player"
frameborder="0"
allowfullscreen>
</iframe>

Example: Using the sandbox Attribute

html

<iframe src="/form.html" width="600px" height= "450px" sandbox></iframe>

<!--Default sandbox value is restricted to submit any form or script. To submit the form you need to allow it with sandbox. Try using sandbox="allow-forms" and it will let you submit the form. -->

This prevents the embedded page from running scripts or submitting forms - improving security.

Targeting Links to an Iframe

You can load content dynamically into an iframe using the name attribute.

html

<iframe name="myFrame" width="600" height="300"></iframe>

<a href="https://www.wikipedia.org" target="myFrame">Open Wikipedia in Iframe</a>

When you click the link, it loads inside the iframe instead of opening a new page.

Iframe Best Practices

  • Use the title attribute for accessibility.
  • Add sandbox to improve security.
  • Use loading="lazy" to improve performance.
  • Avoid overusing iframes - they can slow down the page and complicate SEO.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes
PreviousHTML Semantic Layout TagsNextHTML Entities & Symbols