Difference in performance between img tag elements vs divs with background images?

前端 未结 6 802
天命终不由人
天命终不由人 2020-12-31 19:42

Are there any differences in performance or load/caching behavior when displaying images in img tags vs divs with image backgrounds?

My example:

6条回答
  •  感情败类
    2020-12-31 19:50

    AFAIK, browsers cache images the same whether they're in a DIV or an IMG. In any case, I think this one of those cases where specific performance is defined as an implementation detail internal to each rendering engine (and possibly the browsers built around them). As such, it's both out of our control as designers/developers and subject to change from browser to browser and version to version. In other words, I wouldn't spend too much time worrying about it.

提交回复
热议问题