HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

HTML Iframes

An HTML iframe (Inline Frame) is an HTML element that allows you to embed another document within the current HTML document. It essentially creates a window or a frame in which an external content, typically from another source or website, can be displayed. The content inside the iframe is independent of the surrounding content on the page.

HTML Iframe Syntax

The HTML <iframe> tag specifies an inline frame.

An inline frame is used to embed another document within the current HTML document.

Syntax

<iframe src="url" title="description"></iframe>
            

Iframe - Set Height and Width

Use the height and width attributes to specify the size of the iframe.

The height and width are specified in pixels by default:

Example
<iframe src="demo_iframe.htm" height="200" width="300" title="Iframe Example"></iframe>
You can click on above box to edit the code and run again.

Output

Iframe - Target for a Link

An iframe can be used as the target frame for a link.

The target attribute of the link must refer to the name attribute of the iframe:

Example

  <iframe src="demo_iframe.htm" name="iframe_a" title="Iframe Example"> </iframe>

 <p> <a href="https://codelines.in/tutorials/html" target="iframe_a">codelines.in </a> </p>  
           
You can click on above box to edit the code and run again.

Output

Iframes are commonly used for various purposes, including embedding maps, videos, external content, advertisements, and more. However, care should be taken when embedding content from external sources to ensure security and user privacy.