Allows the browser to display another web page document within the current document.
<iframe src="URL"></iframe>
Attribute | Description | Value |
src | Specifies URL for image | “https://www.site.com” or relative URL “/nextpage.php |
name | Specifies the name of the iframe | User defined text |
width | Specifies the width | User defined number of pixels, e.g. 400px, or % screen e.g. 50% |
height | Specifies the height | User defined number of pixels, e.g. 400px |
frameborder | Specifies to display a border around the iframe | 0 or 1 |
class | Specifies the class name to be used for CSS styling | User defined class name |
id | Specifies the unique id for CSS or Scripts | User defined unique text id |
longdesc | Specifies a separate page that contains a long description | “https://www.site.com/description.php” or relative URL “/description.php" |
scrolling | Specifies whether scrollbars should be used | yes, no, auto |
An iframe can be used as the target frame for a link by setting the target attribute of the link to the name attribute of the iframe:
<!DOCTYPE html> <html> <head> <title>My Document Title</title> </head> <body> <h1>Here's an iframe:</h1> <iframe src="https://www.tech-academy.co.uk" name="myIframe" width="80%" height="500px"></iframe> <p><a href="https://www.motogp.com" target="myIframe">Why not try MotoGP</a></p> <p><a href="https://www.bbc.co.uk" target="myIframe">Or watch it on BBC iPlayer</a></p> <p><a href="https://www.ducati.com" target="myIframe">Or just buy a nice shiny new Panigale... If only!</a></p> </body> </html>