Skip to main content

Iframes in Html

Iframes:

Iframes are useful in adding sub-pages in the webpage like if you want to add page in page see example at the end.

How to Add an Iframe:
<iframe src="URL"></iframe>

There are 4 basic attributes to add an iframe. usually one, Src="URL" commonly use but suppose if you want to add height and width too so you can do it.

Iframe - How to Set Height and Width:

Height and Width of any iframe allows you to set height and width of any iframe.

<iframe src="URL" width="200" height="200"></iframe>

Change

Height
Width 

with your own values.


Iframe - How to Set Borders of Iframe:

Iframe has border also so this attribute allows you to add some border around this iframe so it shows that this is embeded iframe. 
<iframe src="URL" frameborder="0"></iframe>

Change

frameborder
 
with your own values.

Iframe - Use iframe as a Target for a Link:

An iframe can be used as the target frame for a link.It means that giving url is going to open in your above frame. When you will play with it check it you will surely know this video tutorial showing this.
The target attribute will work for that careful about it.
<iframe src="http://www.google.com" name="iframe_q"></iframe>
<p><a href="http://qtutors.blogspot.com" target="iframe_q">Qtutors in above iframe</a></p> 

We make iframe with some url now we want to open the bottom link within the above iframe so i give the iframe a name and after that i set a hyperlink and target shows that i want to open it in iframe_q.

Comments