I am doing the following:
<a href="www.stackoverflow.com">
<button disabled="disabled" >ABC</button>
</a>
This works good but I get a HTML5 validation error that says “Element ‘button’ must not be nested within element ‘a button’.
Can anyone give me advice on what I should do?
No, it isn’t valid HTML5 according to the HTML5 Spec Document from W3C:
In other words, you can nest any elements inside an
<a>except the following:<a><audio>(if the controls attribute is present)<button><details><embed><iframe><img>(if the usemap attribute is present)<input>(if the type attribute is not in the hidden state)<keygen><label><menu>(if the type attribute is in the toolbar state)<object>(if the usemap attribute is present)<select><textarea><video>(if the controls attribute is present)If you are trying to have a button that links to somewhere, wrap that button inside a
<form>tag as such:However, if your
<button>tag is styled using CSS and doesn’t look like the system’s widget… Do yourself a favor, create a new class for your<a>tag and style it the same way.