Home >Web Front-end >CSS Tutorial >What is the difference between the img attribute alt and title?
When we add attributes to pictures, when we first learn, we may confuse the difference between alt and title. Then we can look at the difference between the two from the original meaning——
The original word of alt is "Alternate" means to switch or replace. Commonly used input method switching uses the alt key to switch between Chinese and English. According to Youdao, the standard definition is as follows:
title is the title, theme, the title of a certain object. If the article has an article title, its function is to summarize the article. .
So, it’s easy to distinguish. In the HTML document editing img tag, alt is used to replace the description when img cannot be displayed, telling people what is here; and title is to describe the picture. Theme, no matter whether the picture is displayed or not, as long as the img tag exists, when the mouse points to the location of img, the title content will appear.
Let’s look at the examples:
Example 1, the picture can be displayed,
Example 2, the picture is not displayed,
In short;
alt is used to describe the object that cannot be displayed when the picture cannot be displayed; it is not displayed when the picture is displayed;
title is the picture The title theme, as long as the img tag exists, regardless of whether the image is displayed, it will appear when the mouse is stopped here;
The above is the detailed content of What is the difference between the img attribute alt and title?. For more information, please follow other related articles on the PHP Chinese website!