Home > Software design >  Button as a Link
Button as a Link

Time:04-29

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>

CodePudding user response:

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.

  • Related