HTML Iframes

What is HTML Iframes?

HTML Iframes is known as an inline frame. It allows us to present a web page within the same web page.

Basically, it is like opening a window inside a web page.

Check if your browser supports iframes. If not, upgrade your browser

Syntax1:
<iframe src=”www.tutorialbrain.com”></iframe>

Syntax2:
<iframe src=”www.tutorialbrain.com” name=”myframename”></iframe>

Syntax3:
<iframe src=”www.tutorialbrain.com” width=”200″ height=”150″></iframe>

Example of Iframes

<iframe src="https://www.tutorialBrain.com/">
</iframe>

Height and width of Iframes

You can also set height and width of Iframes.

Example

<iframe src="https://www.tutorialbrain.com/" 
   height="400px" width="100%">
</iframe>

All HTML Iframe attributes

iframe attribute Description
src used to provide the URL of the iframe(inline frame)
name name attribute provides a name to the <iframe>.
width and height to give width and height of iframe.

Note/warning/suggestion/improvement:

Some of the iframe properties are deprecated in HTML5. Example – frameborder, scrolling, marginwidth,marginheight etc.

deprecated iframe attribute Description
frameborder to provide a border to the frame - deprecated in HTML5
scrolling scrolling options: yes/no/auto - deprecated in HTML5
marginwidth width margin of the iframe - deprecated in HTML5
marginheight height margin of the iframe - deprecated in HTML5

Interview Questions & Answer

HTML iframes are known as an inline frame. It allows us to present a web page within the same web page. We can also set the width and height of the iframes. Using iframe tag we can show webpage inside a webpage.
The best example for iframes is, if you want to embed facebook like and share button to your webpage.

Syntax1:
<iframe src="www.tutorialbrain.com"></iframe>

Syntax2:
<iframe src="www.tutorialbrain.com" name="myframename"></iframe>

Syntax3:
<iframe src="www.tutorialbrain.com" width="200" height="150"></iframe>

Example:-

<!DOCTYPE html>
<html>
<body>

<iframe src="https://TutorialBrain.com/">
<p>Your browser does not support iframes.</p>
</iframe>
<!-- Iframes in HTML is known as inline frame. It allows us to present a web page within the same web page.-->

</body>
</html>

The HTML iframe tag is used to create a nested webpage. The HTML iframe tag defines an inline frame.
For example:-

<!DOCTYPE html>
<html>
<body>

<iframe src="https://TutorialBrain.com/">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>

Tutorials for all brains!