
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to use height and width attributes in HTML?
The height and width attribute in HTML is used to specify the height and width of the element. The values are set in px i.e. pixels.
The height and width attribute is used in the following HTML elements:
S. No | Elements | Attribute | Attribute |
1 | <canvas> element | height | width |
2 | <embed> element | height | width |
3 | <iframe> element | height | width |
4 | <img> element | height | width |
5 | <input> element | height | width |
6 | <object> element | height | width |
7 | <video> element | height | width |
To add an image in an HTML page, <img> tag is used. With that, we need to use the attributes height and width to set the height and width of the image in pixels.
Example
You can try to run the following code to learn how to use height and width attributes in HTML.
<!DOCTYPE html> <html> <head> <title>HTML height and width attribute</title> </head> <body> <img src="https://www.tutorialspoint.com/green/images/logo.png" alt="Simply Easy Learning" width="200" height="70"> </body> </html>
- Related Articles
- How to use image height and width attribute in HTML Page?
- How to set cell width and height in HTML?
- How to use min and max attributes in HTML?
- How to set viewport height and width in CSS
- How to adjust the width and height of an iframe to fit with content in it HTML?
- How to add and remove HTML attributes with jQuery?
- HTML Attributes
- Why cannot I use iframe absolute positioning to set height/width
- How to get the height and width of the android.widget.ImageView?
- How to get the Width and Height of the screen in JavaScript?
- How to get the width and height of an android.widget.ImageView in Kotlin?
- How to set table width in HTML?
- The width and height properties in CSS
- Width and Height of Elements in CSS
- How to add attributes to an HTML element in jQuery?

Advertisements