Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF2 ignores empty alt attribute

I have a jsf snippet:

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets">
<!-- Yandex.Metrika -->
<img src="//mc.yandex.ru/watch/xxx" alt=""/>
<!-- /Yandex.Metrika -->
</ui:composition>

But when I use it, web-client get HTML page whithout empty alt attribute in img element:

<!-- Yandex.Metrika -->
<img src="//mc.yandex.ru/watch/xxx" />
<!-- /Yandex.Metrika -->

As result my document has validation error (

How can I solve this problem?

like image 851
Dmitry Avatar asked Nov 04 '10 00:11

Dmitry


People also ask

What is an empty ALT attribute?

Answer. Alt tags are used to describe the contents of images, but some images don't convey any meaning and are therefore considered "decorative." Decorative images do not need to be announced by the screen reader, so if the alt attribute is empty (alt="", aka a "null" tag) it will not be announced to the user.

When might an empty alt attribute be the correct value when might an empty alt attribute be the correct value?

The alt attribute is the text equivalent of the image, which means that it should only be empty if the meaning of the image is already encapsulated by the surrounding text.


1 Answers

You could use the JSF graphicImage component, which does render the empty alt attribute.

For Example:

<h:graphicImage value="#{resource['images:image1.png']}" alt="" />

or

<h:graphicImage value="http://somedomain.com/somecontext/xxx/image1.png" alt="" />
like image 114
Tim Brückner Avatar answered Nov 15 '22 06:11

Tim Brückner