Waseem Barcha Waseem Barcha - 2 years ago 108
HTML Question

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"/>


<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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download