An iframe (short for inline frame) is an HTML element that allows an external webpage to be embedded in an HTML document. Unlike traditional frames, which were used to create the structure of a webpage, iframes can be inserted anywhere within a webpage layout.
An iframe can be inserted into an HTML document using the iframe tag, as shown in the example below:
<iframe src="http://sharpened.com/example.php" width="728" height="90"></iframe>
The code above would insert the contents of the URL into a 728 x 90 px inline frame within the webpage. The iframe source (src) can reference an external website or another page on the same server, such as src="/example.php". The width and height attributes are not required, but are commonly used to define the size of the iframe. Other iframe attributes, such as marginwidth and marginheight are supported in HTML 4 and earlier, but in HTML5, CSS is used to customize the appearance of an iframe.
Iframes are used for several different purposes, such as online advertising and multimedia. Many ad platforms use iframes to display ads on webpages since they provide more flexibility than an inline script. Since iframes may contain an entire webpage, advertisers can include extra tracking code within an iframe that helps ensure accurate reporting for both the advertiser and publisher.
Iframes are also used for displaying different types of media within a webpage. For example, YouTube videos and Google Maps windows are often embedded in webpages using iframes. Many web applications use iframes since they can display dynamic content without reloading the webpage.
Latest Updates on Mar 11, 2020