61
iema
7y

My teammate used p tag and made it look like a button using css.

He has 10 years of web development experience.

Comments
  • 7
    Welcome to devrant

    I do that quite often because you can give properties more easily to a div than a button
  • 2
    @RazorSh4rk Thanks!

    I forgot to mention that the button needs to link to another page. It's a news site so we really need to pay attention to semantics.
  • 3
    He could have used <b>, deprecated and still valid tag. Fontawsome uses <I>
  • 2
    See he knows all that CSS from 10 years of experience
  • 8
    When we are bored we style the script tags.
  • 4
    My go to tag is <span> personally. I avoid <button> because of it's resistance to styling and avoid <a> because I don't want to bother with event.preventDefault(). But this is of course only when I'm using JavaScript click events. Who would have thought 'onclick' would make a comeback?
  • 3
    @Benji-dev preventDefault is unnecessary, use href="javascript:void(0)"
  • 1
    @norman70688
    Any inline js is actually uncool, because it's mixing functionality and page structure, thus reducing ease of maintainability.

    Except now we have React and JSX :)

    Tightly coupling and inlining javascript within the view has come back around. Which is why I was joking onclick has made a comeback ;)
    didn't say you couldn't style it, I just said it was more resistant to styling than say, a span.

    When I'm prototyping, I can quickly make a button using a span tag on the fly like so: http://codepen.io/anon/pen/...

    Notice how the actual button element is resistant to the same styling? To properly style the button cross-platform/browser I need to do something like this: https://codepen.io/terkel/pen/...

    which I can't do from memory so yeah, I just don't unless I'm already using a css framework or existing styles that do that already.

    I know all about semantics and accessibility. that's why we have 'role': https://goo.gl/nuP0Sk
  • 0
    @jacojvvdev except now it does nothing. If I want have some kind of js handler for that link, I might as well put the function there and prevent the default behavior as the first line of that function.
  • 1
    @Benji-dev I only use it when building spas, not everywhere.

    Everythig has a right place to be used.
  • 0
    @jacojvvdev I mostly build SPAs. I just assumed that it would interfere with an event listener or an onclick handler that actually handles to logic of the button but maybe not? I guess depends on the framework as well.
  • 0
    @Benji-dev I use Vue, so the binding is with @click. So it does not interfere.
  • 1
    It's really problematic that some devs don't want or take the time to learn about new technologies and good practises.
    It's another problem that there are many ways to solve such problems and many different opinions on what is best practise.
  • 1
    @Dollique that's why I find lot of rants pretty useful, you learn, sometimes a lot, and maybe you peer at what made you rant in the first place under a different light, that may or may not cast the shadow of a justification or even some reason in it
Add Comment