HTML images - how to use <img> tag

The HTML <img> tag is used to allows to insert/link images in a HTML document.

The img tag contains two required attributes - src (URL of the image) and alt (alternate description if the image cannot be displayed).

Attributes

The img tag supports the global and event attributes.

alt
Defines an alternate content if the image cannot be displayed
crossorigin
Allows third party images to be used within a canvas
height
Defines the height of the image
ismap
Defines if the image is a server-side image map
longdesc
Defines a URL that show detailed information about the image
sizes
Defines multiple images of different sizes for different layouts. This allows specifying and displaying different images in desktop and mobile browsers.
src
Defines a URL for the image
srcset
Defines different URLs for different layout. This is used in conjunction with sizes attribute.
usemap
Defines if the image is a client-side image map
width
Defines the width of the image

Examples:

<body> <div> <img src="file.jpg" width="200" height="100" alt="" /> </div> </body>

More Information:

Check out the image tutorial to get more information on how to use images.