HTML height Attribute

Definition and Usage

The height attribute specifies the height of the element, in pixels.

Applies to

The height attribute can be used on the following elements:

Examples

Canvas Example

A <canvas> element with a height and width of 200 pixels:

<canvas id="myCanvas" width="200" height="200" style="border:1px solid">

Embed Example

A Image with a height and width of 200 pixels:

<embed src="love.jpg" width="200" height="200">

Iframe Example

An <iframe> with a specified height and width of 200 pixels:

<iframe src="/" width="200" height="200">
</iframe>

Img Example

An image with a height and width of 42 pixels:

<img src="smiley.png" alt="Smiley face" height="42" width="42">

Input Example

Define an image as the submit button, with height and width attributes:

<form action="/action_page.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="image" src="img_submit.png" alt="Submit" width="auto" height="48">
</form>

Object Example

A Image with a height and width of 400 pixels::

<object data="love.jpg" height="400" width="400"></object>

Video Example

A video player with a specified height and width:

<video width="320" height="240" controls>
<source src="love.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

Browser Support

The height attribute has the following browser support for each element:

Element          
canvas 4.0 9.0 2.0 3.1 9.0
embed Yes Yes Yes Yes Yes
iframe Yes Yes Yes Yes Yes
img Yes Yes Yes Yes Yes
input 1.0 Yes 16.0 Yes 1.0
object Yes Yes Yes Yes Yes
video Yes Yes Yes Yes Yes

Comments