Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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:

Elements Attribute
<canvas> height
<embed> height
<iframe> height
<img> height
<input> height
<object> height
<video> height

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">
Try it Yourself »

Embed Example

A flash animation with a height and width of 200 pixels:

<embed src="helloworld.swf" width="200" height="200">
Try it Yourself »

Iframe Example

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

<iframe src="/default.asp" width="200" height="200">
</iframe>
Try it Yourself »

Img Example

An image with a height and width of 42 pixels:

<img src="smiley.gif" alt="Smiley face" height="42" width="42">
Try it Yourself »

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.gif" alt="Submit" width="48" height="48">
</form>
Try it Yourself »

Object Example

A flash animation with a height and width of 400 pixels::

<object data="helloworld.swf" height="400" width="400"></object>
Try it Yourself »

Video Example

A video player with a specified height and width:

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>
Try it Yourself »

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

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.