For this method, my primary concern is accessibility. Without the alt tag and any HTML, a simple div with background-image doesn't have good accessibility.
Another issue is that you'd have to use an image aspect ratio to calculate the padding (spacing) needed for the background image which may lead to code bloat if you have lots of images with various aspect ratios.
As for optimization, we need to optimize them by compression and resizing (if needed).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What is your thought about adding images via background in CSS?
background-image:url(img/myimage.jpg);Can images added via this method be optimized using
pictureorsrcset, or do you just have to optimize them by resizing and compressing? thxFor this method, my primary concern is accessibility. Without the
alttag and any HTML, a simpledivwithbackground-imagedoesn't have good accessibility.Another issue is that you'd have to use an image aspect ratio to calculate the padding (spacing) needed for the background image which may lead to code bloat if you have lots of images with various aspect ratios.
As for optimization, we need to optimize them by compression and resizing (if needed).