HTML - Iframes

Overview

Estimated time: 20–30 minutes

Iframes embed external or internal documents. Use accessibility and security attributes.

Examples

<iframe src="/page.html" title="Example" loading="lazy"></iframe>
<iframe src="/demo.html" title="Demo" sandbox="allow-scripts allow-forms" referrerpolicy="no-referrer"></iframe>

Try it

Common Pitfalls

  • Missing title (hurts accessibility).
  • Overly permissive sandboxes for third-party content.

Exercises

  1. Embed a local demo with loading="lazy" and a minimal sandbox.