Inputting a default image in case the src attribute of an html

后端 未结 22 2450
渐次进展
渐次进展 2020-11-22 16:02

Is there any way to render a default image in an HTML tag, in case the src attribute is invalid (using only HTML)? If not, what would

22条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 16:20

    There is no way to be sure the myriad number of clients (browsers) that will try to view your page. One aspect to consider is that email clients are defacto web browsers and may not handle such trickamajickery ...

    As such you should ALSO include an alt/text with a DEFAULT WIDTH and HEIGHT, like this. This is a pure HTML solution.

    alt="NO IMAGE" width="800" height="350"
    

    So the other good answer would be slightly modified as follows:

    NO IMAGE
    

    I had issues with the object tag in Chrome, but I would imagine this would apply to that as well.

    You can further style the alt/text to be VERY BIG ...

    So my answer is use Javascript with a nice alt/text fallback.

    I also found this interesting: How to style an image's alt attribute

提交回复
热议问题