Kanbritech Learn logo
HTML HTML Tutorial 45h track

HTML Iframes

Write an iframe for help.html with a descriptive title and a sandbox.

Understand the topic

An iframe embeds a separate browsing context. It can show another document, a map, or a controlled example. Supply a descriptive title and consider whether the embed is necessary. sandbox restricts capabilities, while allow grants selected policy-controlled features. Other sites can block framing, and cross-origin documents generally cannot be read directly by the parent page.

Worked example

<iframe title="Example welcome message" srcdoc="<h1>Welcome</h1><p>This is a separate document.</p>" sandbox style="width: 100%; border: 1px solid #64748b;"></iframe>

srcdoc provides the embedded document directly. An empty sandbox attribute applies restrictions without granting script execution.

Practice

Write an iframe for help.html with a descriptive title and a sandbox.

Show a suggested answer
<iframe src="help.html" title="Registration help" sandbox></iframe>

Common mistake

Do not embed every lesson merely to display text. Direct HTML is easier to style, navigate, and make accessible.

HTML documentation

Live Example

Try Coding

Result