📜  HTML-iframes(1)

📅  最后修改于: 2023-12-03 14:41:57.545000             🧑  作者: Mango

HTML iframes

HTML iframes allow you to embed another HTML document within the current HTML document. This is helpful if you want to display another website within your own, or if you want to display a video or map within your website without redirecting the user.

Syntax

To create an iframe tag, you use the

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

In addition to the "src" attribute, there are several other attributes that you can add to your iframe tag:

  • width and height: Specify the dimensions of the iframe in pixels.
  • scrolling: Set to "yes" or "no" to enable or disable the scrollbars within the iframe.
  • frameborder: Set to "1" or "0" to enable or disable the border around the iframe.
  • allowfullscreen: Set to "true" to allow the iframe to go into fullscreen mode.
Examples
<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" width="560" height="315"></iframe>
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3024.872564779447!2d-74.0059416845944!3d40.712775990732216!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c24fa5d33f083b%3A0xc80b8f06e177fe62!2sStatue+of+Liberty+National+Monument!5e0!3m2!1sen!2sus!4v1565696624115!5m2!1sen!2sus" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
Notes
  • Make sure to specify the dimensions of the iframe, otherwise it may not display correctly.
  • Be careful when embedding external websites, as this can potentially create malicious security vulnerabilities.