HTML Images Creating an image


To add an image to a page, use the image tag.

Image tags (img) do not have closing tags. The two main attributes you give to the img tag are src, the image source and alt, which is alternative text describing the image.

<img src="images/hello.png" alt="Hello World">

You can also get images from a web URL:

<img src="" alt="StackOverflow user Caleb Kleveter">

Note: Images are not technically inserted into an HTML page, images are linked to HTML pages. The <img> tag creates a holding space for the referenced image.

It is also possible to embed images directly inside the page using base64:

<img src="data:image/png;base64,iVBOR..." alt="Hello World">

Tip: To link an image to another document, simply nest the <img> tag inside <a> tags.