HTML height Attribute
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.
Example
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
Tablets & Mobile
Last updated by CSSPortal on: 29th March 2024
