html tutorial - height Attribute in HTML - html5 - html code - html form

Learn html - html tutorial - Height attribute in html - html examples - html programs
- The height attribute is used to define the height of the elements, which is in pixels.
- We can use the attribute in <canvas>, <embed>, <iframe>, <img>, <input>, <object> and <video>.
Syntax for height attribute in HTML:
<img height="pixels">
Differences between HTML 4.01 and HTML 5 for height Attribute:
HTML 4.01
- The <canvas>, <embed> and <video> tag are not supported in HTML4.
- For the <iframe> tag, the height should be defined in pixels or in % of the containing element.
HTML 5
- The <canvas>, <embed> and <video> tag are are newly added.
- For the <input> tag, the height attribute is added in HTML5.
- For the <iframe> tag, the height value must be in pixels.
Applies To:
Element | Attribute |
---|---|
<canvas> | height |
<embed> | height |
<iframe> | height |
<img> | height |
<input> | height |
<object> | height |
<video> | height |
height Attribute Value in HTML:
Value | Description |
---|---|
pixels | Specifies the height of the elements. |
Sample Coding for height Attribute in HTML:
Tryit<!DOCTYPE html>
<html>
<head>
<title>Wikitechy HTML height Attribute</title>
</head>
<body>
<img src="https://www.wikitechy.com/images/logo.png" height="100"
width="200">
</body>
</html>
Code Explanation for height Attribute in HTML:

- The height attribute specifies the height of the image is 100px.
Output for height Attribute in HTML:

- The height of the output image is 100px.
Browser Support for height Attribute in HTML:
Element | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
<canvas> | 4 | 9 | 2 | 3.1 | 9 |
<embed> | Yes | Yes | Yes | Yes | Yes |
<iframe> | Yes | Yes | Yes | Yes | Yes |
<img> | Yes | Yes | Yes | Yes | Yes |
<input> | 1 | Yes | 16 | Yes | 1 |
<object> | Yes | Yes | Yes | Yes | Yes |
<video> | Yes | Yes | Yes | Yes | Yes |