Open In App

How to specify the address of the document to embed in the iframe element in HTML5?

Improve
Improve
Like Article
Like
Save
Share
Report

The iframe in HTML stands for Inline frame. The “iframe” element in a webpage helps to display another web page document within some particular area or region using the web browser. The inline frame is used to embed another webpage within the current HTML webpage having different attributes for loading, setting height or width, allowing full screen mode, src, and many more.

Approach: The task is to define an address of the document embedded in an iframe element. The task can be done by simply  using the src attribute of the iframe tag in the document. This property is used to specify the URL of the document that is embedded to the <iframe> element.  

Syntax:

<iframe src="URL">

Example: Below code illustrates the use of the src attribute in the <iframe> element. 

HTML




<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body style="text-align:center;">
     
    <h2 style="color:green">GeeksforGeeks</h2>
     
    <b>Specify the address of the document to embed in the HTML iframe element</b><br/>
     
<p> This is the normal webpage content</p>
 
    <iframe src=
           height="200" width="400">
    </iframe>
</body>
 
</html>                


Output: 

          

Example 2: The below code uses the iframe element without the scrollbar and frameborder using the respective iframe attributes. The attributes are “scrolling=no” and “frameborder=0” as shown in the example.

HTML




<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body style="text-align:center;">
     
    <h2 style="color:green">GeeksforGeeks</h2>
     
    <b>Specify the address of the document to embed in the HTML iframe element</b><br/>
     
<p> This is the normal webpage content</p>
 
     
<p>Another content</p>
 
    <b>no content, no scroll in below iframe</b><br/>
    <iframe src=
           height="200" width="400"
           scrolling="no" frameborder="0"
           name="myFrame"
           >
    </iframe>
</body>
 
</html>                


Output:

         

 



Last Updated : 27 May, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads