Use the <img> tag in HTML to display an image. The following are the attributes −
Attribute | Value | Description |
---|---|---|
Align | top bottom middle left right | Deprecated− Specifies the alignment for the image. |
Alt | text | Specifies alternate text |
Border | pixels | Deprecated − Specifies the width of the image border. |
crossorigin ![]() | anonymous use-credentials | It allows images from third-party sites that allow cross-origin access to be reused with canvas. |
Height | pixels or % | Specifies the height of the image. |
hspace | pixels | Deprecated − Amount of white space to be inserted to the left and right of the object. |
Ismap | URL | Defines the image as a server-side image map. |
Longdesc | text | Deprecated − Specifies a URI/URL of a long description - this can elaborate on a shorter description specified with the alt attribute. |
Src | URL | the url of an image |
Usemap | #mapname | Defines the image as a client-side image map and used alongwith <map> and <area> tags. |
Vspace | pixels | Deprecated − Amount of white space to be inserted to the top and bottom of the object. |
Width | pixels or % | Sets the width of an image in pixels or in %. |
Example
You can try to run the following code to add an image to a web document −
<!DOCTYPE html> <html> <head> <title>HTML img Tag</title> </head> <body> <img src = "https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg" alt = "Learn HTML5" height = "250" width = "270" /> </body> </html>