Windows 上的 Safari 不支持 HTML 中 img 标签的 alt 属性吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2348392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is the alt attribute for img tag in HTML not supported by Safari on Windows?
提问by rohitmishra
When I use the alt
attribute with img
tag in Safari on Windows, instead of displaying the alternate text, Safari only shows a "?" in a box. Is this a bug in Safari on Windows, or Safari is missing this feature.
当我在 Windows 上的 Safari 中使用alt
带有img
标签的属性时,Safari 只显示一个“?”,而不是显示替代文本。在盒子里。这是 Windows 上 Safari 中的错误,还是 Safari 缺少此功能。
回答by John Himmelman
Every browser has its own magical way of rendering alternate text. It seems to be a standards issue, hopefully to be resolved in the future HTML5 specs.
每个浏览器都有自己神奇的呈现替代文本的方式。这似乎是一个标准问题,希望在未来的 HTML5 规范中得到解决。
IE, Firefox, & Opera render the alternative text inside IMG for broken images. Chrome & Safari also do this, but the text will be cutoff you unless you set the height/weight of the image.
IE、Firefox 和 Opera 会在 IMG 中为损坏的图像呈现替代文本。Chrome 和 Safari 也这样做,但除非您设置图像的高度/重量,否则文本将被截断。
Here is an excellent article on the issue (with screen caps that show how each browser renders the alt text).
这是一篇关于这个问题的优秀文章(带有显示每个浏览器如何呈现替代文本的屏幕截图)。
http://rebuildingtheweb.com/en/how-should-browsers-render-alt-text/
http://rebuildingtheweb.com/en/how-should-browsers-render-alt-text/
More screenies from the Paceillo Group's blog...
http://www.paciellogroup.com/blog/misc/HTML5/alt-tests/screenshots.html
http://www.paciellogroup.com/blog/?p=498
更多来自 Paceillo Group 博客的屏幕截图...
http://www.paciellogroup.com/blog/misc/HTML5/alt-tests/screenshots.html
http://www.paciellogroup.com/blog/?p=498
回答by vpram86
Never use alt
for rendering tooltips. Use title
instead. It is supported by almost all browsers. alt
is meant to be an alteranative text which should come only if the image is unavailable/cannot be displayed or for some Assistive technologies like screen readers while reading the page.
切勿alt
用于渲染工具提示。使用title
来代替。几乎所有浏览器都支持它。alt
旨在成为替代文本,仅当图像不可用/无法显示或在阅读页面时使用某些辅助技术(如屏幕阅读器)时才应出现。