HTML height Attribute

Last Updated : 20 May, 2026

The HTML height attribute specifies the height of an element, defining how tall it appears on a webpage.

  • Used to set the height of elements like <img>, <video>, <iframe>, etc.
  • The value is usually given in pixels.
  • Helps control the size and layout of elements.
  • Can also be set using CSS for better flexibility.

Syntax:

<element height="value" >

HTML Elements Supporting Height Attribute

The height attribute can be applied to these elements to control their vertical size.

  • <canvas>: <canvas> is used for drawing graphics dynamically.
  • <embed>: Embeds external content like multimedia in HTML documents.
  • <iframe>: <iframe> embeds another webpage within an HTML document.
  • <img>: <img> displays images in an HTML document.
  • <object>: <object> embeds external content or plugins in HTML documents.
  • <input>: <input> allows user input within forms in HTML documents.

Example : HTML height attribute sets the height of a canvas element, defining its vertical dimension, often used for rendering graphics or animations.

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>HTML height Attribute</title>
</head>

<!--Driver Code Ends-->

<body>
    <h2>HTML height Attribute</h2>
    <!-- canvas Tag starts here -->
    <canvas id="GeeksforGeeks" 
            width="200" 
            height="100" 
            style="border: 1px solid black">
    </canvas>
    <!-- canvas Tag ends here -->
</body>

<!--Driver Code Starts-->

</html>
<!--Driver Code Ends-->
Comment