HTML img alt Picture alternative text

 The function of the HTML img alt attribute is to create image alternative text . This image alternative text is quite similar to img title , but the difference is that img alt is used when the image is wrong or invalid (for example, the image is removed or the server permission is modified) , Let the browser display the alternative text, but when the mouse is moved to the picture, the alternative text will not be displayed, which is equivalent to the filing of the picture. If the picture in the article is invalid, the web designer may not want an x , If the img alt attribute is set, readable text can be displayed.


HTML img alt syntax example
<img src="Image URL" alt="Alternative text for the image to be displayed">
HTML img alt attribute example
<img src="#" alt=""> <img src="#" alt="This is image alternative text">
The effect of the example
 This is image alternative text
In the example, two img tags are prepared, but there are no actual pictures. The effect of img alt is deliberately tested. The alt of one picture is empty, and the other has the text to set alt. Readers and friends can use IE, What is the difference between FireFox, Google Chrome, and Opera?

Although the img alt is only effective when the image is invalid, the alt attribute is used in the IE browser. When the mouse mentions the image, the alternative text will still be displayed. Other common browsers such as Google Chrome and FireFox , Opera These will not be displayed. In addition, some versions of Google Chrome cannot display the alternate text effect of img alt.

The alternative text of HTML img alt can be written in Traditional Chinese, which is usually used to indicate the content of the image or the link of the image. For example, when the HTML <a> tag is used for the image, it is recommended not to put too much meaningless in the alt tag To mislead the reader.

Post a Comment

0 Comments