Nearby lessons

18 of 24

🧩 HTML Iframes

📌 What are HTML Iframes?

The <iframe> tag in HTML allows you to embed another HTML page within the current one. 🌐

It's useful for displaying external content like videos, maps, or other web pages.

📄 Basic Iframe Example

Example02
🌐Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🖼️ Image in Iframe Example

Example03
🌐Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🎥 YouTube Video in Iframe Example

Example04
🌐Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔒 Sandboxed Iframe Example

Example05
🌐Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

✅ Best Practices

  • Always use the title attribute for accessibility. 🏷️
  • Use sandbox to restrict iframe capabilities 🔐
  • Avoid embedding untrusted content to prevent security issues ⚠️
  • Use loading="lazy" to improve performance ⚡

🧠 Test Your Knowledge

3 Questions
Progress: 0 / 3