Image breadth attribute

Definition and usage

breadth Attribute set or return the breadth of the image breadth attribute The value.

The HTML breadth attribute specifies the width of the image.

This attribute can also return the width of the image using CSS styles (see the example below).

Tip:Please use height attribute Set or return the breadth of the image height attribute The value.

Example

Example 1

Change the width of the image to 450px:

document.getElementById("myImg").breadth = "450";

Try it yourself

Example 2

Return the width of the image:

var x = document.getElementById("myImg").breadth;

Try it yourself

Example 3

Change the height and width of the image to 300px and 450px respectively:

document.getElementById("myImg").height = "300";
document.getElementById("myImg").breadth = "450";

Try it yourself

Example 4

Return the width of the image using CSS styles:

var x = document.getElementById("myImg").breadth;

Try it yourself

Syntax

Return the breadth attribute:

imageObject.breadth

Set the breadth attribute:

imageObject.breadth = pixels

Αξία attribute

Αξία Περιγραφή
pixels Πλάτος σε pixels (π.χ. width="100").

Τεχνικά λεπτομέρειες

Αποτελέσματα: Αριθμός, που δείχνει το πλάτος της εικόνας σε pixels.

Υποστήριξη browser

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη

Σχετικές σελίδες

Εγχειρίδιο HTML:HTML <img> attribute width