-2

Why IE and Firefox cannot open a link inside the button tag, In chrome it opens the link in same window.

Example:

<button type="button"><a href="http://stackoverflow.com">stackoverflow</a></button>
Brian Luna
  • 682
  • 1
  • 8
  • 28
  • Button is meant to initiate some action. If you are expecting just a redirection, you can remove the button. And if you want the button appearance you can use style sheet with anchor tag to achieve it. Even it chrome you are not supposed to do that. However as per the chrome implementation it can deal with it. It doesn't mean that you can use tags in that way. – Karpak Dec 22 '16 at 03:59

2 Answers2

2

It'not allowed to have link inside a button, according to HTML5 specifications

HTML5 reference from W3

Content model: Phrasing content, but there must be no interactive content descendant.

a is interactive content descendant

Interactive content description

fg78nc
  • 4,774
  • 3
  • 19
  • 32
1

I don't know why but you should do it like this:

<a href="http://stackoverflow.com"><button type="button">stackoverflow</button></a>
Hezron
  • 352
  • 1
  • 15