Computer >> Computer tutorials >  >> Programming >> HTML

How to use image height and width attribute in HTML Page?


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. Just keep in mind to specify both these attributes.

How to use image height and width attribute in HTML Page?

Example

You can try the following code to add height and width attribute to the image in an HTML page −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Document</title>
   </head>

   <body>
      <img src = ”/green/images/logo.png” alt = "We Learners" width = ”170” height = ”70”>
   </body>
</html>