- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - Iframes
An iframe is an inline frame that allows us to embed another document within the current HTML document. In HTML, the inline frame is defined with the <iframe> tag. This tag creates a rectangular region at specified place within the HTML document in which the browser can display an external document such as a map or another web page.
Syntax
<iframe src="url" title="description"></iframe>
URL or path of the external document is attached using the src attribute of <iframe> tag. If the content of iframe exceeds the specified rectangular region, HTML automatically includes the scrollbars. HTML allows any number of iframes, but, it may affect the performance of the website. Always include a title attribute for the <iframe> that wwill help screen readers to read out what is the content provided in the iframe.
Examples of HTML iframes
Bellow exammples will illsutarte the usage of iframes, we have covered multiple examples to clarify the use cases of iframes where, when and how you can use it.
Creating an iframe
An inline iframe is used to embed an another document inside the current html document. Following is the example to show how to use the <iframe> in HTML.
<!DOCTYPE html> <html> <head> <title>HTML Iframes</title> </head> <body> <p>It is an example of HTML Iframe</p> <iframe src="/index.htm"> Sorry your browser does not support inline frames. </iframe> </body> </html>
Setting Height and Width of Iframes
To set height and width (dimension) of an HTML Iframe, we use the height and width attribute of <iframe> tag.
<!DOCTYPE html> <html> <head> <title>HTML Iframes</title> </head> <body> <p>Setting Height and width of HTML Iframe </p> <iframe src="/index.htm" width="500" height="300"> Sorry your browser does not support inline frames. </iframe> </body> </html>
Removing border of Iframes
By default iframes carry border style within it, so we can remove that border using CSS border Property.
<!DOCTYPE html> <html> <head> <title>HTML Iframes</title> </head> <body> <p>Removing border of Iframes</p> <iframe src="/index.htm" width="500" height="300" style="border:none;"> Sorry your browser does not support inline frames. </iframe> </body> </html>
Iframe for a Hyperlink
To create a target Iframe for a hyperlink, we use the name attribute of <iframe> tag. The value of this attribute is used in the target attribute of elements like <form> and <a> to specify the target frame.
<!DOCTYPE html> <html> <head> <title>HTML Iframes</title> </head> <body> <p> Click on the link below to load the content inside the specified frame... </p> <p> <a href="/html/html_iframes.htm" target="Iframe"> Iframe Tutorial </a> </p> <iframe style="background-color: skyblue;" name="Iframe" width="500" height="300"> Sorry your browser does not support inline frames. </iframe> </body> </html>