Propriété alignde l'image
Objet Image
Définition et utilisation
La propriété align peut définir ou renvoyer la valeur de l'attribut align de l'image.
La propriété align spécifie l'alignement par rapport au contenu en ligne.
Syntaxe
imageObject.align=value
L'attribut align peut avoir les valeurs suivantes :
| Valeur | Description |
|---|---|
| left | Aligne l'image à gauche |
| right | Aligne l'image à droite |
| middle | Aligne l'image au centre |
| top | Aligne l'image en haut |
| bottom | Aligne l'image en bas |
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge l'attribut align
Exemple
Exemple
L'exemple suivant aligne l'image à droite en fonction du texte environnant :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function alignImg(){
document.getElementById("compman").align="right";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" alt="Computerman" width="107" height="98">
<p>Some text. Some text. Some text. Some text. Some text.</p>
<input type="button" onclick="alignImg()" value="Align Image">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function alignImg(){
document.getElementById("compman").align="right";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" alt="Computerman" width="107" height="98">
<p>Some text. Some text. Some text. Some text. Some text.</p>
<input type="button" onclick="alignImg()" value="Align Image">
</body>
</html>
Essayez-le vous-même »
Objet Image Autres extensions