Hacker News new | ask | show | jobs
by ARCarr 3231 days ago
What are you supposed to do about image alt text when the image is purely decorative, like a border?

This complains about alt="".

1 comments

Some people would say use a div and background image CSS property. Not sure if that's the recommended solution though.
Well - I would try to omit the image at all and use border style properties to do it. This way I would omit an request totally.

But maybe someone with real experience (not some hobbyist when it comes to front end work) should chime in.

Per https://www.w3.org/wiki/HTML/Elements/img

> A purely decorative image that doesn't add any information In general, if an image is decorative but isn't especially page-specific, for example an image that forms part of a site-wide design scheme, the image should be specified in the site's CSS, not in the markup of the document. However, a decorative image that isn't discussed by the surrounding text but still has some relevance can be included in a page using the img element. Such images are decorative, but still form part of the content. In these cases, the alt attribute must be present but its value must be the empty string.

I have always understood that (and earlier spec incarnations) to mean that <img alt=''> is correct for these cases.