Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

W3C Validation: Attribute alt not allowed on element a at this point

While running through the W3C validation service, I encountered this error message:

Attribute alt not allowed on element a at this point.

The validator complains after the "Four Fortune 500 Companies reside: " content. Here is my HTML markup:

<div id="container">
    <header>
        <h1><a href="index.html">Metropolitan+<b>Seattle</b></a></h1>
        <nav>
            <ul>
                <li><a href="buildings.html">Buildings</a></li>
                <li id="contact">Contact Us</li>
            </ul>
        </nav>
    </header>
</div>
<div class="image-section">
    <img src="img/seattleskyline.jpg" alt="Seattle Skyline" id="center-image" />
    <div id="caption"><div id="caption-text">A panoramic view of 1201 Third Avenue at night</div></div>
    <button id="sliderLeft" onclick="left();"></button>
    <button id="sliderRight" onclick="right();"></button>
</div>
<br><br>
    <div class="content">
        Four Fortune 500 companies reside: 
<a href="http://www.amazon.com/"alt="Amazon Website"><b>Amazon.com (#49)</b>
</a>, <a href="http://www.starbucks.com" alt="Starbucks Website"><b>Starbucks (#208)</b></a>, <a href="http://shop.nordstrom.com" alt="Nordstrom Website"><b>Nordstrom (#227)</b></a>, and <a href="http://www.expeditors.com" alt="Expeditors Website"><b>Expeditors International (#428)</b></a>. 
    </div>
    <br><br>
like image 735
Henry Zhu Avatar asked May 24 '15 06:05

Henry Zhu


2 Answers

You want to use title attribute, not alt.

like image 76
Andrew Avatar answered Oct 11 '22 07:10

Andrew


For anchor tag, alt is not a valid attribute, please use title attribute.

Please refer http://www.w3.org/TR/html4/struct/links.html

like image 35
Sashant Pardeshi Avatar answered Oct 11 '22 08:10

Sashant Pardeshi