In this section, we will learn what the height attribute is and how to use it.
What is height Attribute in HTML <img> Tag?
The height attribute in HTML <img> element is used to set the height of the target image in the document.
You should know by default, browsers use the default height of the target image when they render it in a page. So if the height is, for example, 100 pixels, then the rendered image in the document would have the same height!
But depending on the structure of our document, we might need to change the height of the target image. This is where we can use the height attribute.
HTML height Attribute in <img> Tag Syntax:
<img src = “image” height = “value”>
<img> Tag height Attribute Values
The value we set for the height attribute could be any number with supported relative and absolute units.
Example: using height attribute in HTML <img> tag
See the Pen using height attribute in HTML <img> tag by Omid Dehghan (@odehghan) on CodePen.