Skip to main content

What is an iframe and how it works?

The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one. Each embedded browsing context has its own session history and document. The browsing context that embeds the others is called the parent browsing context. The topmost browsing context — the one with no parent — is usually the browser window, represented by the Window object.

<!DOCTYPE html>
<html>
<head>
<title>HTML5 iframe</title>
</head>
<style type="text/css">
iframe {
border: 1px solid #333;
width: 50%;
}
.output {
background: #eee;
}
</style>
<body>
<p>The Inline iFrame Example</p>
<iframe id="inlineFrameId"
title="Inline iFrame Example"
width="300"
height="200"
src="https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik">
Sorry your browser does not support inline frames.
</iframe>
</body>
</html>
info

Because each browsing context is a complete document environment, every <iframe> in a page requires increased memory and other computing resources.