HTML Iframes - website in website


Iframes in HTML allows embedding another HTML page into the current one - website in website.

Iframe syntax

<iframe src="https://codedocs.org" width="500" height="300" title="CodeDocs.org"></iframe>

Result of the code above:


Attributes used in in the iframe:

  • src="" - address of the website you want to show in the iframe
  • width="" - width of iframe
  • height="" - height of iframe
  • title="" - description or name of the page you are displaying - recommended to use

Other attributes you can use in the iframe:

  • frameborder="" - iframe border size
  • allowfullscreen="" - allow activating iframe to fullscreen mode


Changing iframe URL

To change iframe URL address to another directly from HTML, you can use <target> attribute to <a> tag. Please see example below.


By: Tomas Silny
Edited: 2020-11-08 18:10:30
Source: developer.mozilla.org/