HTML <img> Tag
The <img> tag defines an image in an HTML page.The <img> tag has two required attributes: src and alt.
Attributes
Attribute | Value | Description |
---|---|---|
align | top bottom middle left right |
Not supported in HTML5. Specifies the alignment of an image according to surrounding elements |
alt | text | Specifies an alternate text for an image |
border | pixels | Not supported in HTML5. Specifies the width of the border around an image |
crossorigin | anonymous use-credentials |
Allow images from third-party sites that allow cross-origin access to be used with canvas |
height | pixels | Specifies the height of an image |
hspace | pixels | Not supported in HTML5. Specifies the whitespace on left and right side of an image |
ismap | ismap | Specifies an image as a server-side image-map |
longdesc | URL | Specifies a URL to a detailed description of an image |
sizes | Specifies image sizes for different page layouts | |
src | URL | Specifies the URL of an image |
srcset | URL | Specifies the URL of the image to use in different situations |
usemap | #mapname | Specifies an image as a client-side image-map |
vspace | pixels | Not supported in HTML5. Specifies the whitespace on top and bottom of an image |
width | pixels | Specifies the width of an image |
Example
<!DOCTYPE html> <html> <body> <img src="logo.png" alt="logo" width="50" height="50"> </body> </html>