HTML img tag: title attribute vs. alt attribute?

后端 未结 11 777
悲&欢浪女
悲&欢浪女 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:26

    You should not use title attribute for the img element. The reasoning behind this is quite simple:

    Presumably caption information is important information that should be available to all users by default. If so present this content as text next to the image.

    Source: http://blog.paciellogroup.com/2010/11/using-the-html-title-attribute/

    HTML 5.1 includes general advice on use of the title attribute:

    Relying on the title attribute is currently discouraged as many user agents do not expose the attribute in an accessible manner as required by this specification (e.g. requiring a pointing device such as a mouse to cause a tooltip to apear, which excludes keyboard-only users and touch-only users, such as anyone with a modern phone or tablet).

    Source: http://www.w3.org/html/wg/drafts/html/master/dom.html#the-title-attribute

    When it comes to accessibility and different screen readers:

    • Jaws 10-11: turned off by default
    • Window-Eyes 7.02: turned on by default
    • NVDA: not supported (no support options)
    • VoiceOver: not supported (no support options)

    Hence, as Denis Boudreau adequately put it: clearly not a recommended practice.

提交回复
热议问题