What is the difference between the img attribute alt and title?

一个新手
Release: 2017-10-20 09:14:35
Original
2825 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!