CSS Portal

HTML height Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
height
HTML AttributeThis attribute is supported by all modern browsers.
Updated 29th March 2024

Description

The HTML height attribute specifies the height of an element. It can be used on various elements, including but not limited to <img>, <iframe>, <embed>, <video>, and <canvas>, to directly define how tall the element should be displayed. The value of the height attribute can be specified in different units, such as pixels (px) or percentages (%), depending on the context and the specific element it's applied to. When used with images, for example, specifying the height helps the browser to allocate space on the page before the image is fully loaded, which can improve the layout stability during loading. It's important to note, however, that setting the height without considering the aspect ratio of content like images or videos might lead to distortion. Therefore, it is often recommended to use this attribute in conjunction with the width attribute to maintain the original aspect ratio of the content.

Syntax

<tagname height="pixels">

Values

  • pixelsA numeric height in pixels.

Applies To

Example

<img src="images/sunset.jpg" alt="Image description" height="100" width="200">
Open in editor

Browser Support

The following information will show you the current browser support for the HTML height attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee