<img> element displays an image on the web page.
<img src="image URL" alt="text used for accessibility" />
<img> element has no closing tag and it cannot have other tags inside of it. It uses attributes to set properties, some of which include:
srcsets the URL or filename of images that support many formats (GIF, JPEG, PNG, etc.).`
altis an alternative text used by screen readers and when the image does not load.
heightis the height of the image, measured in pixels.
widthis the width of the image, measured in pixels.
Below is an example of an image wrapped in an
<a> element which creates an image link:
<html><head> </head><body><a href="https://codecademy.com"><imgsrc="cc_logo.png"alt="Codecademy Home Page"width="256"height="64"/></a></body></html>
This is what the rendered image look like:
- Not-Ethan48 total contributions
- christian.dinh2481 total contributions
- Anonymous contributorAnonymous contributor3077 total contributions
- short_matthew_f33 total contributions