What’s good practice for <button>?
Can it replace <a> tag or is it only meant for forms?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A link links to something – at least it should! It is semantically wrong to do the following:
This should be replaced with a button, as it is there for that purpose – it works as a trigger for something the user (programmer) specifies; the purpose of a
<button type="button">element is thus not clear. In contrast, the purpose of a link is very clear – it should point somewhere!As HTML is a markup language, it does not matter all that much what you do, if you do not think SEO. You can achieve the same thing with a
<a>tag as you can with a<button>tag, like a<span>can act exactly as a<div>– semantically though, it is incorrect.