Home  >  Article  >  Web Front-end  >  HTML tutorial: title attribute and alt attribute_HTML/Xhtml_Web page production

HTML tutorial: title attribute and alt attribute_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:43:281540browse

XHTML is the basis of CSS layout. jb51.net has always emphasized the learning of XHTML knowledge, paying attention to semantics and document structure. The title and alt attributes give me the most intuitive feeling that they can improve the adaptability of the document and reasonably increase the keyword density. In the XHTML standard, the alt attribute of images is required.
XHTML is the basis of CSS layout. jb51.net has always emphasized the learning of XHTML knowledge, paying attention to semantics and document structure. The title and alt attributes give me the most intuitive feeling that they can improve the adaptability of the document and reasonably increase the keyword density. In the XHTML standard, the alt attribute of images is required.
alt attribute
For user agents (UA) that cannot display images, forms, or applets, the alt attribute is used to specify replacement text. The language of the replacement text is specified by the lang attribute. The Alt attribute (note that it is "attribute" rather than "label") contains replacement instructions, which is required for images and image hotspots. It can only be used in img, area, and input elements (including applet elements). For input elements, the alt attribute is intended to replace the submit button image.
For example: Use the alt attribute to provide text descriptions for viewers who cannot see the images in your document. This includes users who use browsers that do not natively support image display or have image display turned off, users who are visually impaired and users who use screen readers. Alt text is used to replace an image rather than provide additional descriptive text.
Think carefully before writing alt text to make sure that it actually provides information for people who can’t see the image and that it makes sense in context. For decorative images, use an empty value (alt="", no spaces between quotes) instead of irrelevant replacement text such as "blue bullet" or "spacer.gif". Don't ignore it. If you ignore it, some screen readers will read the file name of the image file directly, and text browsers like Lynx will display the file name of the image file, and that will be of no use to your browser.
It is easiest to set alternative text for images containing text. Generally speaking, the text contained in the image can be used as the alt attribute value.
title attribute
The title attribute provides suggested information for the element on which this attribute is set.
The title attribute can be used in all tags except base, basefont, head, html, meta, param, script and title. But it's not necessary. Maybe that's why many people don't understand when to use it.
Use the title attribute to provide non-essential additional information. Most visual browsers display the title text as a tool tip when the mouse is hovering over a specific element. However, it is up to the manufacturer to decide how to render the title text. Some browsers will display the title text in the status bar. For example, early versions of the Safari browser.
A good use of the title attribute is to add descriptive text to a link, especially when the link itself does not clearly express the purpose of the link. This way visitors know where the links will take them and they won't load a page that they may not be interested in at all. Another potential application is to provide additional descriptive information for images, such as dates or other non-essential information.
 The title attribute value can be set longer than the alt attribute value. Be aware, however, that some browsers will truncate text that is too long (such as tooltips or other). For example, Mozilla's core browser can only display the first 60 characters. This is considered a Mozilla bug and is something you should be aware of.
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