w1coding.comAll tutorials

JavaScript Iframes

JavaScript lessons
  1. Environment Setup
  2. Introduction
  3. Enviroment
  4. Basics
  5. Variables
  6. Operators
  7. Condition
  8. Functions
  9. Arrays
  10. Bjects
  11. DOM
  12. Objects
  13. Colors
  14. DOM
  15. Events
  16. Validation
  17. JSON
  18. Error
  19. Callbacks
  20. Promises
  21. Fetch
  22. Local
  23. Modules
  24. Animation
  25. Classes
  26. Iframes
  27. Responsive

What is an iframe?

The <iframe> element is used to embed another document within the current HTML document. It creates a nested browsing context, allowing you to display content from another source, such as another webpage or multimedia content.

How to Use iframe

You can define an iframe in your HTML using the <iframe> tag. Here’s a basic example:

<iframe src="https://www.example.com"></iframe>

The src attribute specifies the URL of the page to embed.

Examples of iframe

Example 1: Basic iframe

Here is a simple iframe that loads a webpage:

Example 2: iframe with Additional Attributes

This iframe includes width, height, and border attributes:

Example 3: Responsive iframe

This iframe is styled to be responsive: