Skip to content
Related Articles

Related Articles

Improve Article

HTML Iframes

  • Difficulty Level : Medium
  • Last Updated : 07 May, 2021

Significance of Iframe in HTML:

The iframe in HTML stands for Inline Frame. The ” iframe ” tag defines a rectangular region within the document in which the browser can display a separate document, including scrollbars and borders. An inline frame is used to embed another document within the current HTML document.

Iframe is basically used to show a webpage inside the current web page.
 

The ‘ src ‘ attribute is used to specify the URL of the document that occupies the iframe.

Syntax : 



<iframe src="URL"></iframe>

Attributes and their Examples

1. Height and Width: The height and width attributes are used to specify the size of the iframe. The attribute values are specified in pixels by default, but they can also be specified in percentages like ” 80% “.
 

html




<!DOCTYPE html>
<html>
  
<body>
    <p>Content goes here</p>
            height="300" width="400">
    </iframe>
  
</body>
  
</html>

Output: 
 

2. Border:

  • Removing Border: By default, iframe has a border around it. To remove the border, we must use the style attribute and use the CSS border property.

    HTML




    <!DOCTYPE html>
    <html>
      
    <body>
        <p>Content goes here</p>
                height="300" width="400" style="border:none;">
        </iframe>
      
    </body>
      
    </html>

    Output: 
     

  • Border Style: Changing the size, style, and color of the Iframe’s border :

    html




    <!DOCTYPE html>
    <html>
      
    <body>
      
        <p>Content goes here</p>
         height="300" width="400" style="border:4px solid orange;">
      
        </iframe>
      
    </body>
      
    </html>

    Output: 
     

3. 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.
 

html




<!DOCTYPE html>
<html>
  
<body>
    <p>Click the link text</p>
  
    <iframe height="300" width="350" src=
            name="iframe_a">
    </iframe>
    <p>
      <a href=
         target="iframe_a">
       GeeksforGeeks IDE
      </a>
    </p>
  
  
</body>
</html>

Output:

  • Before clicking the link text

  • After Clicking link text:

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :