I notice this in people's code a lot where they create a button (styled as button etc for example in a to do list) and I'll wonder why they aren't using a button tag but an a naming the class to btn/button/etc. Wondering if there are any specific reasons to do this and which is better practice?
CodePudding user response:
Use an a
tag when you want to navigate to a new page or an external resource i.e. links.
Use a button
tag to perform an action like to open a modal, delete an item, close a modal, etc.
CodePudding user response:
- a tag is used for link & navigation.
- button is for actions (form validation, add item...)