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).
If true then that frame can be opened in full screen.
height
Pixels
It defines the height of the embedded iframe, and the default height is 150 px.
name
text
It gives the name to the iframe. The name attribute is important if you want to create a link in one frame.
frameborder
1 or 0
It defines whether iframe should have a border or not. (Not supported in HTML5).
Width
Pixels
It defines the width of embedded frame, and default width is 300 px.
src
URL
The src attribute is used to give the path name or file name which content to be loaded into iframe.
sandbox
This attribute is used to apply extra restrictions for the content of the frame
allow-forms
It allows submission of the form if this keyword is not used then form submission is blocked.
allow-popups
It will enable popups, and if not applied then no popup will open.
allow-scripts
It will enable the script to run.
allow-same-origin
If this keyword is used then the embedded resource will be treated as downloaded from the same source.
srcdoc
The srcdoc attribute is used to show the HTML content in the inline iframe. It overrides the src attribute (if a browser supports).
scrolling
It indicates that browser should provide a scroll bar for the iframe or not. (Not supported in HTML5)
auto
Scrollbar only shows if the content of iframe is larger than its dimensions.
yes
Always shows scroll bar for the iframe.
no
Never shows scrollbar for the iframe.
Let's go to the next page.
Get link
Facebook
X
Pinterest
Email
Other Apps
Comments
Popular posts from this blog
HTML File Paths An HTML file path is used to describe the location of a file in a website folder. File paths are like an address of file for a web browser. We can link any external resource to add in our HTML file with the help of file paths such as images, file, CSS style sheet file, JavaScript file, video, etc. The src or href attribute requires an attribute to link any external source to HTML file. Different types to specify file paths: <img src="picture.jpg"> It specifies that picture.jpg is located in the same folder as the current page. <img src="images/picture.jpg"> It specifies that picture.jpg is located in the images folder in the current folder. <img src="/images/picture.jpg"> It specifies that picture.jpg is located in the images folder at the root of the current web. <img src="../picture.jpg"> It specifies that picture.jpg is located in the folder one level up from the current folder. There are two types...
Tags of HTML With description Basic HTML Tag Description <!DOCTYPE> Defines the document type <html> Defines an HTML document <title> Defines a title for the document <body> Defines the document’s body <h1> to <h6> Defines HTML headings <p> Defines a paragraph <br> Inserts a single line break <hr> Defines a thematic change in the content <!–…–> Defines a comment Formatting Tag Description <acronym> Not supported in HTML5. Use <abbr> instead. Defines an acronym <abbr> Defines an abbreviation or an acronym <address> Defines contact information for the author/owner of a document/article <b> Defines bold text <bdi> Isolates a part of text that might be formatted in a different direction from other text outside it <bdo> Overrides the current text direction <big> Not supported in HTML5. Use CSS instead. Defines big text <blockquote> Defines a section that is quoted from another s...
Comments
Post a Comment