开发者

common problems with images html

Are there any common problems why alt attributes on images wont work.

Tested for IE8 Standards 开发者_开发百科mode.

Thanks in adv.


if you want to show text from alt attrib, use title='' attrib.

The difference:

  • alt shows up instead of img - when img cant load
  • title shows up when you mouseover the image


alt means just that, an alternative for when the image isn't displayed. If you want a tooltip, use title or longdesc. Historically alt has been abused to mean this, but IE8 has finally fixed this.


By "not work" I'm assuming you mean that the alt text doesn't appear when you hover over the image. You'll need to use the title attribute if you always want the text to appear in all browsers:

<img src="foo.png" alt="bar" title="bar" />


Yes, you should always specify the alt attribute for these reasons:

  • In case image is not found:
    • The text from alt will be shown instead
  • The alt tag is important in terms of Search Engine Optimization (SEO)
  • Accessibility reasons
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜