Home  >  Article  >  Web Front-end  >  Detailed graphic explanation of the difference between alt and title in the img attribute

Detailed graphic explanation of the difference between alt and title in the img attribute

黄舟
黄舟Original
2017-10-21 10:35:003011browse

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 intention——

altThe original word is "Alternate", which means switching and replacing. 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 Provide a summary description of 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 see the example:

Example 1, the picture can be displayed,

Example 2, the picture is not displayed,

In short;

alt is a description of the object that cannot be displayed when the picture cannot be displayed. Function; it does not appear when the picture is displayed;

title is the title theme of the picture. As long as the img tag exists, regardless of whether the picture is displayed or not, it will appear when the mouse stops here;

The above is the detailed content of Detailed graphic explanation of the difference between alt and title in the img attribute. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn