How to create an image in HTML

You can show an image on the page using the <img> tag:

<img src="flowers.jpg" alt="Flowers in a garden">

The src attribute tells the browser where to find the image, and the alt attribute tells the browser what text to display if the image can't be found.

Why is there no closing tag?

Why is there no </img> tag? The <img> tag doesn't need a closing tag (see an explanation here).

You can, however, add a forward slash into the opening tag:

<img src="flowers.jpg" alt="Flowers in a garden"/>

but it is not required.

Next: How to create a button in HTML

Comments

Leave a comment

What color are brown eyes? (spam prevention)
Submit
Code under MIT License unless otherwise indicated.
© 2020, Downranked, LLC.