Home  >  Article  >  What attributes does iframe have?

What attributes does iframe have?

小老鼠
小老鼠Original
2023-08-23 15:27:398699browse

iframe attributes include src attribute, width and height attributes, frameborder attribute, scrolling attribute, allowfullscreen attribute, sandbox attribute, name attribute, etc. Detailed introduction: 1. src attribute, used to specify the URL of the web page or document to be embedded; 2. width and height attributes, used to specify the width and height of the iframe, which can be set using pixel values ​​or percentages; 3. frameborder attributes, etc. wait.

What attributes does iframe have?

The operating environment of this tutorial: Windows 10 system, Dell G3 computer.

iframe is a tag in HTML used to embed another web page or document in a web page. It has properties that can be used to control the presentation and behavior of embedded content.

1. src attribute: The src attribute is used to specify the URL of the web page or document to be embedded. For example, will embed a page named example.html within the current page.

2. width and height attributes: The width and height attributes are used to specify the width and height of the iframe. Can be set using pixel value or percentage. For example, would set the width of the iframe to 500 pixels and the height to 300 pixels.

3. frameborder attribute: The frameborder attribute is used to specify whether to display the border of the iframe. Can be set to 0 or 1. When set to 0, the border is not displayed; when set to 1, the border is displayed. For example, embeds example.html without displaying a border.

4. scrolling attribute: The scrolling attribute is used to specify whether to display scroll bars. Can be set to yes, no or auto. When set to yes, the scroll bar is always displayed; when set to no, the scroll bar is never displayed; when set to auto, the scroll bar is automatically displayed or hidden according to the size of the content. For example, will show or hide scroll bars based on the content size of example.html.

5. allowfullscreen attribute: The allowfullscreen attribute is used to specify whether to allow full-screen display of embedded content. Can be set to true or false. When set to true, full screen display is allowed; when set to false, full screen display is not allowed. For example, will allow example.html to be displayed in full screen mode.

6. sandbox attribute: The sandbox attribute is used to specify whether the content in the iframe runs in a sandbox environment. Can be set to allow-forms, allow-same-origin, allow-scripts, allow-top-navigation or a combination thereof. For example, will run the scripts in example.html in a sandbox environment.

7. name attribute: The name attribute is used to specify the name of the iframe for reference elsewhere. For example, can be referenced elsewhere using the link .

These properties can be combined as needed to control embedded content. By rationally using iframe attributes, you can display multiple contents on a web page at the same time, improving user experience and web page functionality.

The above is the detailed content of What attributes does iframe have?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is iframeNext article:what is iframe

Related articles

See more