본문으로 건너뛰기

<iframe> Tag

<iframe> Tag

The iframe tag is used to display another webpage within a webpage.


Example

Example of an iframe tag
<iframe src="https://example.com" width="500" height="300"></iframe>

Using this code, the example.com webpage will be displayed within a 500x300 size area on the current page.


Key Attributes of the iframe Tag

src

  • The src attribute specifies the URL of the webpage you want to embed.

  • Code example:

    Example of iframe src attribute
    <iframe src="https://example.com"></iframe>

width & height

  • The width and height attributes specify the size of the iframe.

  • Code example:

    Example of iframe width & height attributes
    <iframe src="https://example.com" width="400" height="250"></iframe>

frameborder

  • The frameborder attribute specifies the presence of a border around the iframe. However, this attribute is no longer recommended in modern web browsers. Instead, it is better to use the CSS border property.

  • Code example:

    Example of iframe frameborder attribute
    <!-- Outdated method -->
    <iframe src="https://example.com" frameborder="0"></iframe>

    <!-- Recommended method -->
    <iframe src="https://example.com" style="border: none;"></iframe>

How is it used?

The iframe tag is commonly used to include videos (e.g., YouTube), maps (e.g., Google Maps), or external websites within a webpage.