The alt attribute
The alt
attribute is an alternative text that will be shown if the browser cannot find the image specified in the src
attribute of the img
tag. It is a mandatory attribute for the img
tag. If it is missing, the validator (a program that checks the correctness of HTML and CSS) will complain.
Example
Let's try to put an incorrect path to the image (leave it empty). Instead of the image, we will see the content of the attribute alt
(it seems that this is normal text - but try to copy it - you will not succeed, it will stretch like an image):
<img src="" alt="Picture of a funny monkey">
:
See also
-
attribute
title
,
which sets the tooltip