HTML img tag: title attribute vs. alt attribute?

后端 未结 11 775
悲&欢浪女
悲&欢浪女 2020-12-07 12:01

I was browsing Amazon and I noticed that when searching \"1TB\" if you hover the mouse cursor over the stars rating image, you only see the score if using IE. If you are u

11条回答
  •  鱼传尺愫
    2020-12-07 12:32

    alt and title are for different things, as already mentioned. While the title attribute will provide a tooltip, alt is also an important attribute, since it specifies text to be displayed if the image can't be displayed. (And in some browsers, such as firefox, you'll also see this text while the image loads)

    Another point that I feel should be made is that the alt attribute is required to validate as an XHTML document, whereas the title attribute is just an "extra option," as it were.

提交回复
热议问题