HTML Iframe is used to display a webpage within a webpage.
An HTML iframe embeds another document within the current HTML document in the rectangular region.
Set Width and Height of iframe
You can set the width and height of iframe by using "width" and "height" attributes. By default, the attributes values are specified in pixels but you can also set them in percent. i.e. 50%, 60% etc.
Example:
<!DOCTYPE html>
<html>
<body>
<p>Use the height and width attributes to specify the size of the iframe:</p>
The name of iframe and link target must have same value else link will not open as frame.
[ Window.html ] output code:
<!DOCTYPE html>
<html>
<head>
<style>
p{
font-size: 50px;
color: red;
}
</style>
</head>
<body style="background-color: blue;">
<p>click on link to open new iframe. </p>
</body>
</html>
Embed YouTube video using iframe
You can also add a YouTube video on your webpage using the <iframe> tag. The attached video will be played at your webpage and you can also set height, width, autoplay, and many more properties for the video.
steps to add YouTube video on your webpage:
Go to the YouTube video which you want to add on your page.
Click on the share button and then click on embed option.
which is displayed on the screen and add that code into your page.
Change height, width, and other properties (as per requirement).
Comments
Post a Comment