HTML <img> width Attribute
Example
<img src="img-boy.jpg" alt="Boy" width="300" height="200">
Meaning
The height attribute specifies the width of an image.
Always specify height and width attributes for images.
Standard Syntax
HTML: <img src="URL" alt="text" width="pixels">,
XHTML: <img src="URL" alt="text" width="pixels"/>
Advertisement
Attribute Values
| Value | Description |
|---|---|
| pixels | Specifies the width of the image. |
More Example
Example
<h1>Style Attribute Example</h1>
<img src="img-boy.jpg" alt="Boy" style="width: 300px;height: 150px;">
<h1>Width and Height Attribute Example</h1>
<img src="img-boy.jpg" alt="Boy" width="300px" height="150px">