Is having an empty div to put a background image bad practice?

I'm using a div with a background image because it's the only way I could get the image the right size and position. Positon relative on the container and the absolute on the image wouldn't work for me. So I resorted to this method. Is that okay?
2 Replies
Rägnar O'ock
Rägnar O'ock16mo ago
if the image holds meaningful information yes it is bad practice as assistive technology cannot access it if it's purely for decoration purpose (i.e. it not being here doesn't prevent the user from getting 100% of the information you provide) it's ok. Tho you should try to avoid it as it adds unecessary markup and is hard to understand when you or someone else comes back to it in the future.
croganm
croganm16mo ago
Exactly this, just to double down 🙂
Want results from more Discord servers?
Add your server