Alternative to iFrames in HTML5
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 of the <iframe> tag. There are different alternatives such as:
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: This example shows the implementation of the <embed> tag which is an alternative for the iframe tag in an HTML document.
HTML
<!DOCTYPE html>
< html >
< head >
< title >HTML < embed > Element</ title >
< style >
body {
text-align: center;
}
h1 {
color: green;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h3 >Using < embed > Element</ h3 >
< embed src =
type = "video/mp4" width = "600"
height = "400" >
</ 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 controls, autoplay, and loop to control video playback.
Example: This example shows the implementation of the <video> element which is an alternative for the iframe tag in an HTML document.
HTML
<!DOCTYPE html>
< html >
< head >
< title >HTML < video > Element</ 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 =
type = "video/mp4" >GeeksforGeeks
</ video >
</ 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: This example shows the implementation of the <object> tag which is an alternative for the iframe tag in an HTML document.
HTML
<!DOCTYPE html>
< html >
< head >
< title >HTML < object > Element</ title >
< style >
body {
text-align: center;
}
h1 {
color: green;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h3 >Using < object > Element</ h3 >
< object data =
type = "video/mp4"
width = "600" height = "400" >GeeksforGeeks
</ object >
</ body >
</ html >
|
Output:
Last Updated :
29 Jan, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...