Web Analytics

HTML Images

Beginner ~8 min read

The Image Tag

Images are defined with the <img> tag.

The <img> tag is empty, it contains attributes only, and does not have a closing tag.

The src Attribute

The src attribute specifies the path (URL) to the image.

The alt Attribute

The alt attribute provides an alternate text for an image, if the user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

HTML
CSS
JS

Width and Height

You can use the width and height attributes to specify the width and height of an image.

HTML
CSS
JS

Quick Quiz

Which attribute specifies the path to the image?

A
href
B
src
C
link
D
path