3 ms·
Which of these tags you should use and what they should contain is entirely context dependant. That said, the use of empty alt tags is generally discouraged an
by krono 4y ago
Which of these tags you should use and what they should contain is entirely context dependant.
That said, the use of empty alt tags is generally discouraged and not even allowed together with the ARIA presentation role in most cases.
This decision of theirs will steer developers towards non-compliant/asemantic code. It's really stupid.
https://html.spec.whatwg.org/multipage/images.html#alt https://html.spec.whatwg.org/multipage/images.html#alt
https://w3c.github.io/aria/#presentation https://w3c.github.io/aria/#presentation
https://w3c.github.io/aria-practices/#presentation_role https://w3c.github.io/aria-practices/#presentation_role
- chrisco255 4y agoThat second link from W3C gives this very example: https://w3c.github.io/aria/#example-13 https://w3c.github.io/aria/#example-13 "In the following code sample, the containing img and is appropriately labeled by the caption paragraph. In this example the img element can be marked as presentation because the role and the text alternatives are provided by the containing element." <img src="example.png" role="presentation" alt=""> So empty alt tags are not discouraged.
- krono 4y agoHence the generally discouraged - as in not recommended in the majority of situations but exceptions exist (such as the one you provided).