Propriété widthde l'image
Objet Image
Définition et utilisation
La propriété width définit ou renvoie la valeur de l'attribut width d'une image.
La propriété width spécifie la largeur d'une image.
Syntaxe
imageObject.width=pixels
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la propriété width
Exemple
Exemple
Modifier la hauteur et la largeur de l'image :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple(example.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="Modifier la taille de l'image">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutoriel d'exemple(example.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="Modifier la taille de l'image">
</body>
</html>
Essayez-le vous-même »
Objet Image Autres extensions