Web Tools Table Maker3schools TranslateImage CompressorFavicon Icon GeneratorCrop & Resize Image
Apu
Apu October 13, 2022 › #HowTo #Html

How to set width and height of image in HTML

The width attribute is used to set the width of an image in pixels.

In the below example, I have set the width of the image to 70 pixels.

<img width="70" src="https://app.3schools.in/img/bg.png">

To set the height of an image in pixels, the height attribute is used.

In the below example, I have set the height of the image to 50 pixels.

<img height="50" src="https://app.3schools.in/img/bg.png">

Set width and height of images in HTML #

In this example, we will set the width and the height of an image together in pixels.

Demo : set width and height of an image. #
<img width="70" height="50" src="https://app.3schools.in/img/bg.png">
Try it Yourself »

In this example, we will not set the height and the width attributes to the image . So that you can see how the image looks like with its original height and width.

Demo :- without height and width attributes #
<img src="https://app.3schools.in/img/bg.png">
Try it Yourself »
save
listen
AI Answer
Write Your Answer
loading
back
View All