Button as a Link

55 Views Asked by At

I want to know what is the difference between both codes , the first isn't working while the second is working properly , so what causes this .Help appreciated.

<a href="https://www.google.com" target="_blank">
  <button> Next </button>
</a>

<button>
  <a href="https://www.google.com" target="_blank"> 
    Next Page
  </a>
</button>

1

There are 1 best solutions below

5
Quentin On BEST ANSWER

Both are invalid. HTML does not allow links to contain buttons or vice versa.

The error handling routines in browsers are just different for the two cases.

If you want a link that looks like a button then use a link and apply CSS.