Change the height of an image to 300px:
The height property sets or returns the value of the height attribute of an image.
The height attribute specifies the height of an image.
This property can also return the height of an image that has been styled with CSS (See More Examples).
Tip: Use the width property to set or return the value of the width attribute of an image.
The height property is supported in all major browsers.
Return the height property:
Set the height property:
Value | Description |
---|---|
pixels | The height in pixels (e.g. height="100") |
Return Value: | A Number, representing the height of the image, in pixels |
---|
Return the height of an image:
The result of x will be:
Change the height and width of an image to 300px:
Return the height of an image that has been styled with CSS:
HTML reference: HTML <img> height attribute