Steph LR - Développement

Développement · HTML

Les attributs image

Les attributs d’image en HTML5

Exemple d'image

Exemple complet des attributs d'une image HTML5.

Une sacrée image

Exemple complet

<img src="./test/image.jpg" alt="Une sacrée image" title="chopper 1340 HD" width="320" height="240" loading="lazy" decoding="async">

src

<img src="image.png">

src

Définit la source d'une image, son chemin.

loading

<img src="xxx.png" loading="lazy">

loading

Contrôle le chargement différé (lazy, eager).

width

<img src="test.jpg" width="320">

width

Impose la largeur de l'image.

height

<img src="test.jpg" height="240">

height

Impose la hauteur de l'image.

alt

<img src="test.jpg" alt="Description de l’image">

alt

Texte de remplacement de l'image. Important pour les lecteurs d'écran et le SEO.

title

<img src="test.jpg" title="Tips de l’image">

title

Affiche un tips au survol de l'image.

decoding

<img src="test.jpg" decoding="async">

decoding

Indique au browser la manière de décoder l'image.

sizes

<img srcset="image-320.jpg 320w, image-640.jpg 640w" sizes="(max-width:320px) 100vw, 640px">

sizes

Définit la largeur d'affichage prévue de l'image selon la taille de l'écran.