Featured, How to

How to embed iframe in html

November 13, 2020

An iframe or inline frame is used to display external objects including other web pages within a web page. An iframe pretty much acts like a mini web browser within a web browser. Also, the content inside an iframe exists entirely independent from the surrounding elements.

The basic syntax for adding an iframe to a web page can be given with:

<iframe src="URL"></iframe>

The URL specified in the src attribute points to the location of an external object or a web page.

The following example display “hello.html” file inside an iframe in current document.

<iframe src="hello.html"></iframe>
Setting Width and Height of an iFrame

The height and width attributes are used to specify the height and width of the iframe.

<iframe src="hello.html" width="400" height="200"></iframe>

You can also use CSS to set the width and height of an iframe, as shown here:

<iframe src="hello.html" style="width: 400px; height: 200px;"></iframe>

You Might Also Like