DEV Community

Discussion on: Web Development Bad Habits to Kick

Collapse
 
davwheat profile image
David Wheatley

Do not use a button just to "style a link". Buttons are intended to perform actions on the current page.

Side note: also please don't use anchor elements which have onclick event handlers and a placeholder href (e.g. #) -- use a button instead.

Collapse
 
lizlaffitte profile image
Liz Laffitte • Edited

I wasn’t very clear with this. Often I see people using divs with an internal link where they should probably use a button element. For example, opening modals, paging through multi-page forms, etc.

Collapse
 
Sloan, the sloth mascot
Comment deleted
 
bclonan profile image
Bradley Morgan Clonan

Because they're crappy coders but amazing at code exercises.

Collapse
 
davwheat profile image
David Wheatley

Yeah, that I completely agree with. :)

Collapse
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

this does not depend on the place you put'em but the context where the items are and the most important is what the user expect to happen. Most UX studies reveal that there are many differences depending on the professional market it's web app is working, cultural history, target of the web app and so.

If your users expect a button (layout) which triggers an action (logic) that according to standards or for convenience needs to be an "a" tag then use an "a" tag and add the proper styles to make it look like a button instead of being stubborn and use a button (which merely purpose is to trigger a "submit" in its context).

If we start talking about A11Y or this kind of things that nobody takes care of excepting when you need to build an application for people with some particular disability (usually never) then it's another story and we can discuss with that in mind.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
lofibytes profile image
Jillian S. Estrella (she/her)

Being cruel to people isn't a good look, and certainly doesn't make a positive contribution to this community. Folx are here to learn, not to exchange vitriol.