If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

HTML: The image tag

The <img> tag is used to insert images into a page. It has two required attributes:
NameValue
srcThe URL of the image.
altA description of the image, used by visually impaired people with screen readers and by the browser if it can't find the image at that URL.
It has two optional attributes for changing the size, which can also be changed with CSS. If you change the size, try not to squash or stretch the image. It's best to only specify one of them, and let the browser decide the other.
NameValue
widthThe width of the image, either a number (pixels) or a percentage of the page width.
heightThe height of the image, a number (pixels).

Want to join the conversation?

No posts yet.