HTML iframe Tag
HTML iframe Tag
The iframe tag is used to specify an inline frame. Its basic purpose is to embed another document in the current HTML document. For best practices, we can use the title attribute inside it for better user readability. We can style it by assigning it the id or class attribute.
Attribute Explanation:-
Attribute | Value | Description |
---|---|---|
allow | Specifies a feature policy for iframe. | |
allowfullscreen | true false |
Set to true if iframe can activate fullscreen mode by calling requestFullscreen() method. |
allowpaymentrequest | true false |
Set to true if cross-origin iframe should be allowed to invoke Payment Request API |
height | pixels | Specifies height of an iframe. Its default is is 150px. |
loading | eager lazy |
Specifies whether a browser should load an iframe immediately or to defer loading of iframes until some conditions are met |
name | text | Specifies name of an iframe. |
referrerpolicy | no-referrer no-referrer-when-downgrade origin origin-when-cross-origin same-origin strict-origin-when-cross-origin unsafe-url |
Specifies which referrer information to send when fetching iframe. |
sandbox | allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-top-navigation |
Enables an extra set of restrictions for content in an iframe. |
src | URL | Specifies address of document to embed in iframe. |
srcdoc | HTML_code | Specifies HTML content of page to show in iframe. |
width | pixels | Specifies width of an iframe. Default width is 300 pixels. |
Syntax:-
Its syntax is:- < iframe >