html中图片不可用如何处理,HTML – 当img无法显示时应该发生什么?

似乎没有严格的规则. HTML规范仅描述了浏览器的行为方式,但对浏览器没有规定要求遵循上述行为的规范要求. CSS规范甚至没有触及它.

Section 10.4.2 of W3C HTML5描述了如何根据一组引用img元素所代表的规则来呈现img元素.

Section 4.7.1,向下,根据其src和altattributes描述img元素所代表的内容:

What an img element represents depends on the src attribute and the alt attribute.

[…]

If the src attribute is set and the alt attribute is set to a value that isn’t empty

The image is a key part of the content; the alt attribute gives a textual equivalent or replacement for the image.

If the image is available and the user agent is configured to display that image, then the element represents the element’s image data.

Otherwise, the element represents the text given by the alt attribute. User agents may provide the user with a notification that an image is present but has been omitted from the rendering.

因此,如果图像不可用,则img元素表示其alt文本(因为没有要表示的图像!).

因此,回到10.4.2节,适用以下规则:

If the element is an img element that represents some text and the user agent does not expect this to change

The user agent is expected to treat the element as a non-replaced phrasing element whose content is the text, optionally with an icon indicating that an image is missing, so that the user can request the image be displayed or investigate why it is not rendering. In non-graphical contexts, such an icon should be omitted.

似乎Firefox最接近这种期望(注意:不是要求),尽管生成的框是替换还是未替换,我不确定.对于其他浏览器也是如此 – 内联块可以替换也可以不替换.请注意,HTML表示“短语元素”,而不是“内联元素”或“内联块元素”,这再次增加了整个事物的模糊性.

当通过用户偏好禁用图像时Chrome所做的不是我所谓的“向用户提供图像存在但已从渲染中省略的通知”,但同样,这也不是必需的.不过,我不明白为什么Chrome认为这是一个好主意.什么是替代文字?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值