HTML
width property
Example
An image with both height and width of 42 pixels:
Try it »
Browser support





All major browsers support the width property.
The width attribute specifies the width of the image, in pixels.
**Tip:** It is a good practice to specify the height and width attributes for an image. If these attributes are set, space can be reserved for the image when the page loads. Without them, the browser cannot know the image's dimensions and cannot reserve appropriate space, so the page layout will change when the image loads.
**Tip:** Do not use the height and width attributes to scale images. If you shrink an image using these attributes, the user must download a large image (even if it looks small on the page). The correct approach is to process the image to an appropriate size with software before using it on the web page.
Differences between HTML 4.01 and HTML5
In HTML 4.01, the width should be defined in pixels or as a percentage of the containing element. In HTML5, the width value must be in pixels.
Syntax
Attribute values
| Value | Description |
|---|---|
| pixels | The width in pixels (such as width="100") |
HTML tag