Jürgen, can you show me website (German) or any other where there is used ALT for background image?
I am asking becuase in HTML & CSS - background do not have ALT, they never had.
Is what Google says in that topic:
No, you cannot directly add alt text to a CSS background image.
Why?
-
alt text is an HTML attribute: The alt attribute is specifically designed for <img> tags (and <area> tags within an <map>) in HTML. Its purpose is to provide a text alternative for images that are part of the content of the page.
-
CSS background images are decorative: Images applied via CSS background-image are generally considered decorative or presentational. They are not part of the semantic content structure of the document. Screen readers and other assistive technologies typically ignore them because they aren't meant to convey crucial information.
The only real solution would be to use "Visually hidden text" method:
I mean visually hidden text that screen readers will pick up but regular users won't see unless they interact with it.
HTML code (basic example how it may look like)
<div style="background-image: url('/background-image.jpg');">
<span class="visually-hidden">Description of the important background image content.</span>
</div>
About your sentence "According to the German Accessibility Enhancement Act (BFSG), background images that convey information must be provided with descriptive alt text" - is not entirely accurate, if I may call it that.
WCAG and Informative Images: WCAG principle 1.1 "Perceivable" states that "Provide text alternatives for any non-text content so that it can be changed into other forms people need, such as large print, braille, speech, symbols or simpler language." There is no word about ALT. If I am wrong, please share orginal text. Yes, I live in EU, so I have probably a very similar law as you have.
Yes, I agree that improvement in that area should be done. So we are both the same side.