alt and title are two attributes we often use in our work, but we have never summarized their differences. Now let’s summarize the usage of both of them.
Same points: They will all float out a small floating layer to display text content.
Differences: 1.alt can only be an attribute of an element, while title can be an attribute of an element or a label, for example:
title .
2.alt attribute is used to specify replacement text. It can only be used in img, area and input elements (including applet elements). It is used to provide users with text descriptions when the pictures on the web page cannot be displayed normally. It understands image information. Note that alt is used to replace images rather than provide additional description text. According to some SEO people, using the alt attribute also has a search engine optimization effect, because search engines cannot directly read image information, and alt can provide text information for it, so it is more friendly to search engines.
The title can be used on any element. Move the mouse over the element and the content of the title will be displayed to achieve the effect of supplementary explanation or prompt.
However, what people usually make mistakes is when the two attributes title and alt are used at the same time in the img tag. In the old version of IE browser, the prompt text displayed when the mouse passes over the image is the alt content, and the title attribute is ignored. This has misled many people. Therefore, if you want to display the content of title in IE, either the title attribute must be consistent with alt, or the alt content must be empty ("" and no spaces). However, in the new version of IE (IE8 and above), this situation no longer occurs.
In addition, when the img tag is nested within the a tag, the title attribute of img takes effect.
【Related Recommendations】
1. Special Recommendation:"php Programmer Toolbox" V0.1 version Download
2. Free h5 online video tutorial
##3.
php.cn original html5 video tutorial
4.
The solution to the problem that the H5 video tag can only play sound but not video
5.
IIS MIME is not registered as MP4 type, the solution to the inability to recognize the vidoe tag
The above is the detailed content of Share the differences and usage of alt and title in h5. For more information, please follow other related articles on the PHP Chinese website!