Differences and usage of alt and title, alttitle usage

Source: Internet
Author: User

Differences and usage of alt and title, alttitle usage

Alt and title are the two attributes that are often used in our work, but they are not summed up. Now I will summarize the usage of the two of them.

Similarities: They all float a small floating layer to display text content.

Differences:

1. alt can only be an attribute of an element, and title can be an attribute or tag of an element, for example, <title> title </title>.

2. the alt attribute is used to specify the replacement text. It can only be used in img, area, and input elements (including applet elements ), it is used to provide text instructions for users to understand image information when images on webpages cannot be normally displayed. Note that alt is used to replace the image instead of providing additional instructions. According to some SEO people, using the alt attribute also has the search engine optimization effect, because the search engine cannot directly read the image information, alt can provide text information for it, so it is more friendly to search engines.

The title can be used on any element. If you move the mouse over the element, the title content will be displayed to provide additional instructions or prompts.

However, what is often mistaken is that the title and alt attributes are used for the img tag at the same time. In the earlier version of Internet Explorer, the prompt text displayed when the mouse passes through the image is alt content, ignoring the title attribute, which has misled many people. Therefore, if you want to display the title content in IE, either the title attribute is consistent with that in alt, or the alt content is empty ("", and spaces are not allowed ). However, this is no longer the case in the new version of IE (IE8 or later.
In addition, when an img label is nested in tag a, the img title attribute takes effect.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.