Balise HTML <iframe>
Exemple
Un cadre en ligne est balisé comme suit :
<iframe src="https://www.w3schools.com" title="W3Schools Free
Online Web Tutorials"></iframe>
Plus d'exemples "Essayez-le vous-même" ci-dessous.
Définition et utilisation
La <iframe>
balise spécifie un cadre en ligne.
Un cadre en ligne est utilisé pour incorporer un autre document dans le document HTML actuel.
Conseil : utilisez CSS pour styliser le <iframe>
(voir l'exemple ci-dessous).
Conseil : Il est recommandé de toujours inclure un attribut de titre pour le <iframe>
. Ceci est utilisé par les lecteurs d'écran pour lire le contenu du fichier <iframe>
.
Prise en charge du navigateur
Element | |||||
---|---|---|---|---|---|
<iframe> | Yes | Yes | Yes | Yes | Yes |
Les attributs
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 |
Attributs globaux
La <iframe>
balise prend également en charge les attributs globaux en HTML .
Attributs d'événement
La <iframe>
balise prend également en charge les attributs d'événement en HTML .
Plus d'exemples
Exemple
Ajouter et supprimer des bordures iframe (avec 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>
Pages connexes
Tutoriel HTML : Iframes HTML
Référence HTML DOM : objet IFrame
Paramètres CSS par défaut
La plupart des navigateurs afficheront l' <iframe>
élément avec les valeurs par défaut suivantes :
iframe:focus {
outline: none;
}
iframe[seamless] {
display: block;
}