Width and Height of an Image in HTML (original) (raw)

Last Updated : 4 Jun, 2026

Width and height of an image can be set using either of the following.

It has attribute value pixels, which are used when you want to set the height and width of the image.

Example 1: Using img attributes

The image will appear with a width 300 and a height 300 pixels

HTML `

GeeksforGeeks logo

`

Example 2: Using CSS

HTML `

GeeksforGeeks logo

`

Example 3: Without Specifying Dimensions

In this example, we will not assign width and height value so the image will display with its original height and width.

HTML `

<img src="https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png" alt="GeeksforGeeks logo"

`

Best Practices