English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <img> height Attribute

The height attribute specifies the height of the image in pixels

 HTML <img> tag

Online Example

Height and width are32Pixel Image:

!DOCTYPE html
<html>
<head>
<title>HTML: <img> height Attribute - Basic Tutorial Website oldtoolbag.com</title>
<body>
<img src="haha.gif" alt="haha face" width="32" height="32">
</body>
</html>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the height attribute.

The height attribute specifies the height of the image in pixels.

Tip:Always specify both the height and width attributes of the image. If height and width are set, the space required for the image is reserved when the page is loaded. However, if these attributes are not set, the browser will not know the size of the image and will not be able to reserve appropriate space for it. The effect is that the page layout will change during loading (when the image is loading).

Tip:Using the height and width attributes to shrink the size of large images forces the user to download the large image (even if it looks very small on the page). To avoid this, please resize the image programmatically before using the page.

HTML 4.01 with HTML5difference

In HTML 4.01In the value, the height can be defined in pixels or as a percentage of the containing element. In HTML5In the value, it must be specified in pixels.

Syntax

<img height="pixels">

Attribute Value

ValueDescription
pixelsHeight in pixels (for example height="50").
 HTML <img> tag