Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

HTML height Attribute

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

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

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

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
-

Last updated by CSSPortal on: 29th March 2024

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!