Mubeen
Mubeen

Reputation: 2492

How are iframes used in html?

What is an iframe, and how is it used in html?

Upvotes: 10

Views: 16953

Answers (4)

Naruto
Naruto

Reputation: 103

An iframe is an HTML element that allows an external webpage to be embedded in an HTML document.

In other words, it’s a website within a website. It’s like embedding a chrome or firefox tab within a page, except that it doesn’t have any toolbars or an address bar or anything visible other than the web page that’s loaded. This allows developers to load one web page within another without the user necessarily knowing that they are separate pages. An iframe may load something as simple as a single like button to an entire web page or documents like pdf and many more.

For example

<iframe src="https://www.birthdaycalculatorbydate.com" width="600px" "height="800px" align="center" scrolling="yes"></iframe>

Original content is from iframeinhtml.com

Upvotes: 0

Saurabh Chandra Patel
Saurabh Chandra Patel

Reputation: 13644

Example of iframe - https://jsfiddle.net/vsaurabhaec/jsgbncf0/

Example with url :

<iframe src="https://www.findertoday.com/address-finder/address/Bhagatpur+Tea+Garden-9953?width=500&access_method=findertoday" target="_parent" width="500" height="270" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>

Example with content :

<iframe id="FileFrame" src="about:blank">
<html><body>test</body></html>
</iframe>

NB : iframe need some security awareness. css and js does not have control over inner part of iframe and this is advantage of iframe ( some time )

Upvotes: 0

Mathias Bynens
Mathias Bynens

Reputation: 149774

The iframe element denotes an inline frame, simple as that.

Example usage:

<iframe src="foo.html">
 <p>Your browser does not support <code>iframe</code> elements.</p>
</iframe>

Upvotes: 0

GShenanigan
GShenanigan

Reputation: 5493

An iframe is an object that allows you to embed external content in your HTML page. You can use it to display other web pages, documents (e.g. PDF) etc (although for complex media types you may want to try the object tag instead).

You can add an iframe to your page like so:

<iframe src ="externalContent.html" width="400" height="300">
  <p>Your browser does not support iframes.</p>
</iframe>

The p tag inside will display if iframes are not supported by the browser being used.

Upvotes: 12

Related Questions