PoTheBox
PoTheBox

Reputation: 21

Element button must not appear as a descendant?

I'm trying to validate m HTML code and it keeps giving me an error

"the element (button) must not appear as a descendant of the (a) element"

This is what I have

<body>
<header>
    <nav>
        <ul class="nav_links">
            <li><a href="index.html">Home</a></li>
            <li><a href="history.html">History</a></li>
            <li><a href="visit.html">Visit</a></li>
        </ul>
    </nav>
    <a class="cta" href="contact.html"><button>Contact</button></a>
    </header>
    </body>

What can I do to sort this?

Upvotes: 1

Views: 2382

Answers (1)

3n6in33r
3n6in33r

Reputation: 95

Try doing something like this: <a href="https://stackoverflow.com" class="button">Go to Stack Overflow</a> instead of adding a button element inside of the anchor element.

<body>
   <header>
      <nav>
         <ul class="nav_links">
            <li><a href="index.html">Home</a></li>
            <li><a href="history.html">History</a></li>
            <li><a href="visit.html">Visit</a></li>
         </ul>
      </nav>
      <a href="https://stackoverflow.com" class="button">Go to Stack Overflow</a>
   </header>
</body>

Example snippet:

Best of luck!

Upvotes: 1

Related Questions