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

前端 未结 6 848
天命终不由人
天命终不由人 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 20:07

    The main performance difference is using background images allows you to use CSS sprites. Having one image contain a large number of images from your page means the user only has to make one request instead of one for each image.

提交回复
热议问题