This <img> element controls how a picture is displayed on a web page.
<img> |
Yes | Yes | Yes | Yes | Yes |
The attributes align, border, hspace, longdesc, and vspace are deprecated in HTML5.
Attribute | Value | Description |
---|---|---|
align | top bottom middle left right |
Not supported in HTML5. Set the alignment of an image |
alt | text | Set an alternate text for an image |
border | pixels | Not supported in HTML5. Set the border width |
crossorigin | anonymous use-credentials |
Allow images from third-party sites used in canvas |
height | pixels | Set the height of an image |
hspace | pixels | Not supported in HTML5. Set the whitespace on left and right side of an image |
ismap | ismap | Set an image as a server-side image-map |
longdesc | URL | Not supported in HTML5. Set the URL to a document containing a long description for the image |
src | URL | the URL of an image |
usemap | #mapname | Set an image as a client-side image-map |
vspace | pixels | Not supported in HTML5. Set the whitespace on top and bottom of an image |
width | pixels | Set the width of an image |
The <img> tag supports the Global Attributes in HTML.
The <img> tag supports the Event Attributes in HTML.
img { display: inline-block; }
A demo showing how to use <img> tag.
<html>
<body>
<img src="http://java2s.com/style/download.png"
alt="The Capitan">
</body>
</html>