Open In App

Alternatives of iframe in HTML

Last Updated : 01 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The iframe is used to embed another HTML document within your current webpage. The HTML <iframe> tag is used to create an inline frame or container. This container allows you to embed another document within your current HTML document. To specify the HTML content of the page to be displayed inside the <iframe>, you can use the "srcdoc" attribute.

The alternatives can be used in place of an iframe.

Using <embed> Element

The <embed> tag in HTML is used for embedding external applications which are generally multimedia content like audio or video into an HTML document. It is used as a container for embedding plug-ins such as Flash animations.

Example: The <embed> tag is an alternative for the iframe tag in an HTML document.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        Alternative of iframe (HTML embed Tag)
    </title>
    
    <style>
        body {
            text-align: center;
        }

        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>

    <h3>Using <embed> Element</h3>
    
    <embed src=
"https://media.geeksforgeeks.org/wp-content/uploads/20240108102825/mern.mp4" 
        type="video/mp4" width="600" height="400">
</body>

</html>

Output:

Using <object> Element

The <object> element is used to display multimedia like audio, videos, images, PDFs, and Flash on web pages. It can also be used for displaying another webpage inside the HTML page. 

Example: The <object> tag is an alternative for the iframe tag in an HTML document.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        Alternative of iframe (HTML object Tag)
    </title>
    
    <style>
        body {
            text-align: center;
        }

        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>

    <h3>Using <object> Element</h3>
    
    <object data=
"https://media.geeksforgeeks.org/wp-content/uploads/20240108102825/mern.mp4" 
        type="video/mp4" width="600" height="400">
        GeeksforGeeks
    </object>
</body>

</html>

Output:

Using <video> Element

The <video> element is used to embed video content on the web page. It allows the addition of video files in many formats such as MP4, WebM, etc. This element supports attributes like controlsautoplay, and loop to control video playback.

Example: The <video> element is an alternative for the iframe tag (It is used for append video) in an HTML document.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        Alternative of iframe (HTML video Tag)
    </title>
    
    <style>
        body {
            text-align: center;
        }

        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h3>Using <video> Element</h3>

    <video width="600" height="400" controls>
        <source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20240108102825/mern.mp4" 
            type="video/mp4">
            GeeksforGeeks
    </video>
</body>

</html>

Output:


Next Article

Similar Reads