Careeroza
Iframes
HTML Iframes
An <iframe> displays another web page inside the current one. It is how YouTube videos, maps and payment widgets are embedded.
<iframe src="url" title="description" width="400" height="300"></iframe>Example
Example
Embed a map (always give an iframe a title for screen readers):
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<iframe
src="https://www.openstreetmap.org/export/embed.html?bbox=78.40%2C17.36%2C78.52%2C17.44&layer=mapnik"
title="Map of Hyderabad"
width="400" height="200" style="border:1px solid #ccc;"
loading="lazy">
</iframe>
</body>
</html>Result
Security
- Add
sandboxto restrict what embedded content can do (no scripts, no forms) unless you allow it. - Many sites forbid being embedded (the
X-Frame-Options/ CSPframe-ancestorsheaders), so their iframe stays blank. - Use
loading="lazy"so off-screen iframes do not slow the page down.