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
,
- 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:
HTML Elements Supporting Height Attribute
The height attribute can be applied to these elements to control their vertical size.
- is used for drawing graphics dynamically.
- Embeds external content like multimedia in HTML documents.
- embeds another webpage within an HTML document.
:
displays images in an HTML document.
- embeds external content or plugins in HTML documents.
- : 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>
<head>
<title>HTML height Attributetitle>
head>
<body>
<h2>HTML height Attributeh2>
<canvas id="GeeksforGeeks"
width="200"
height="100"
style="border: 1px solid black">
canvas>
body>
html>