HTML Image <img> Element
- By Christopher Kielty, updated Jan 10, 2019
Use the <img>
element to place images into a webpage. This works well with raster formats like PNG, JPG, and GIF, and vector formats like SVG. Adding image.png to an html page where image.png is in the same directory is as simple as <img src="image.png">
If image.png is in a different folder, say /img/image.png, then do <img src="/img/image.png">
It is possible to use base64 encoding to embed small images directly into the html document. This does increase the size of the document, however, it decreases the number of extra server requests. This can be especially useful for very small icons, especially if there are a handful of small icons throughout the document.
See also Complete List of HTML Tags