3 ms·
You’ll find it’s because until “recently” (depending on how long you’ve been in this game, cough some of us since before css was even a thing) buttons weren’t s
by aidos 6y ago
You’ll find it’s because until “recently” (depending on how long you’ve been in this game, cough some of us since before css was even a thing) buttons weren’t stylable like they are now.
There’s no good reason to just not use buttons these days, but for a long time that wasn’t the case (cross platform).
- tyingq 6y ago<div> is also substantially older than both <button> and <input type="button">. The only button like thing before HTML4 was <input TYPE=SUBMIT>. And, as you mention, the default styling was typically "make it look like the button in the underlying OS". So there was a lot of inertia from existing code, examples, and docs that predated buttons. And a (misinformed) avoidence of it when it did appear because of styling.
- ogre_codes 6y agoThe button html element is old enough to vote. Since it's introduction, jQuery was born and died. Backbone was created and became obsolete. React took over the internet. Webpack, babel, and node were invented. With all that change, I think it's safe to say web technologies are adopted or not based on inertia. I think you are being over-generous.
- tyingq 6y agoPerhaps. I happen to be in a space with lots of "old enough to vote" code still running. On the other hand, the Compose "button" in gmail is ... a <div>: <div class="T-I T-I-KE L3" style="user-select: none" role="button" tabindex="0" jscontroller="eIu7Db" jsaction="click:dlrqf; clickmod:dlrqf" jslog="20510; u014N:cOuCgd,Kr2w4b" gh="cm">Compose</div>
- ogre_codes 6y agoMaybe came across more crossly than I intended... I have a blog I started in the 90s so I hear you. FWIW, my issue with using divs is not that they should never be used as buttons. It's that few people who use them that way go to the effort of doing it correctly. It's absolutely possible to do it right and have a functioning/ accessible js button. Either go the full way and do it right—with accessibility—or just style the standard components. In most cases the latter is the easiest way to go if you care about getting it right.