Tag HTML <iframe>


Esempio

Un frame inline è contrassegnato come segue:

<iframe src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials"></iframe>

Altri esempi "Provalo da solo" di seguito.


Definizione e utilizzo

Il <iframe>tag specifica un frame inline.

Un frame inline viene utilizzato per incorporare un altro documento all'interno del documento HTML corrente.

Suggerimento: usa i CSS per definire lo stile <iframe> (vedi esempio di seguito). 

Suggerimento: è buona norma includere sempre un attributo title per il file <iframe>. Viene utilizzato dagli screen reader per leggere qual è il contenuto del <iframe> file.


Supporto browser

Element
<iframe> Yes Yes Yes Yes Yes

Attributi

Attribute Value Description
allow   Specifies a feature policy for the <iframe>
allowfullscreen true
false
Set to true if the <iframe> can activate fullscreen mode by calling the requestFullscreen() method
allowpaymentrequest true
false
Set to true if a cross-origin <iframe> should be allowed to invoke the Payment Request API
height pixels Specifies the height of an <iframe>. Default height is 150 pixels
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 the 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 the iframe
sandbox allow-forms
allow-pointer-lock
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation
Enables an extra set of restrictions for the content in an <iframe>
src URL Specifies the address of the document to embed in the <iframe>
srcdoc HTML_code Specifies the HTML content of the page to show in the <iframe>
width pixels Specifies the width of an <iframe>. Default width is 300 pixels


Attributi globali

Il <iframe>tag supporta anche gli attributi globali in HTML .


Attributi dell'evento

Il <iframe>tag supporta anche gli attributi dell'evento in HTML .


Altri esempi

Esempio

Aggiungi e rimuovi i bordi dell'iframe (con CSS):

<iframe src="/default.asp" width="100%" height="300" style="border:1px solid black;">
</iframe>

<iframe src="/default.asp" width="100%" height="300" style="border:none;">
</iframe>

Pagine correlate

Esercitazione HTML: Iframe HTML

Riferimento HTML DOM: IFrame Object


Impostazioni CSS predefinite

La maggior parte dei browser visualizzerà l' <iframe>elemento con i seguenti valori predefiniti:

iframe:focus {
  outline: none;
}

iframe[seamless] {
  display: block;
}