Search code examples
htmlaccessibilityw3cw3c-validation

Can I use same values alt="name" for two or more img html elements in single page?


I am using two logos in one page and my code is

<img src="img/logo/logo-black.png" alt="logo" class="logo-white"/>

and

<img src="img/logo/logo-black.png" alt="logo" class="logo-black"/>

when I validated this code I have receive the following message, I am not sure this is an error or not. Have a look at the screenshot and let me know what is the message about. w3c report


Solution

  • The validation basically says this:

    Your HTML IS validated from a technical point of view, no software will encounter problems when parsing it, but having duplicated ALTs have a very high chance of not accurately representing your pictures and which would then lead to an incorrect information when the image can't be loaded, or incorrect interpretation of your images by screen readers.

    But still, if you're 100% sure your images are the exact same, having the same alt text should be nothing but fine.