Why is it not ok doing <button> <a href=link> content </a> </button> ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is it not ok doing <button> <a href=link> content </a> </button> ?

hey so ive been doing few buttons for my website and when using a code validator it told me that this typo was not ok, so I instead went for : <form action=https://projetdemorgan.neocities.org/biographie.html> <input class=boutons2categ type=submit value="Autobiographie"> </form> but it made me wonder why it's not ok doing as first planned to ? it's working as intended in both ways, so that made me curious thanks

2nd Dec 2019, 4:54 AM
Morgan
Morgan - avatar
3 Answers
+ 2
welcome Morgan
2nd Dec 2019, 5:43 AM
BroFar
BroFar - avatar
+ 1
first off the hyperlink would only work on the text inside the button as a standard hyperlink and therefore the button tags won't work properly the button tags go on the inside of the hyperlink causing the buttons to appear clicked on... <a href="https://projetdemorgan.neocities.org/biographie.html"><button>Biography</button></a>
2nd Dec 2019, 5:27 AM
BroFar
BroFar - avatar
+ 1
Thanks for explaining
2nd Dec 2019, 5:37 AM
Morgan
Morgan - avatar