An image with a height of 600 pixels and a width of 500 pixels:
The width
attribute specifies the width of an image, in pixels.
Tip: Always specify both the height
and width
attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).
Tip: Downsizing a large image with the height
and width
attributes forces a user to download the large image (even if it looks small on the page). To avoid this, rescale the image with a program before using it on a page.
<img width="pixels">
Value | Description |
---|---|
pixels | The width in pixels (e.g. width="100") |
Example:
HTML
<img src="https://horje.com/avatar.png" alt="Girl in a jacket" width="200" height="300">
Type: | Html |
Category: | Web Tutorial |
Sub Category: | HTML Tag |
Uploaded by: | Admin |