SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)

    button vs. input[type="button"]

    So, I've been bouncing back and forth with this for some time now, so I thought I'd post about it and get some other thoughts.

    Which do you use: button or input[type="button"] for your elements? I've bounced back and forth between them. I usually use input for my buttons, but I've been wondering if that's still appropriate.

    Should I use one over the other? Are there advantages or disadvantages to one or the other? I know button can be a bit easier to get an image on, but is that about the only difference?

    Thanks!

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    <button> can contain HTML, and is easier to style with CSS, which actually gets applied across browsers. However, there are some drawbacks to using it in IE. IE doesn't properly detect the value attribute (and uses the tag's content instead as the value), and all values are sent to the server, whether or not the button is clicked. This makes using it as a <button type="submit"> a little tricky.

    <input type="submit"> doesn't have any value or detection issues. However, you can't add HTML like with <button> and can only use the value tag. It's also harder to style, and the styling doesn't always respond well across browsers.

    Here's some relevant links:

    http://stackoverflow.com/questions/4...n-which-to-use

    Coping With Internet Explorer&#39;s Mishandling of Buttons &mdash; All in the head

    http://www.esqsoft.com/html/button-v...als-button.htm

    button versus input[type="submit"] in IE and beyond - Ajaxian

    Input vs. Button | Trevor Davis
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    This makes using it as a <button type="submit"> a little tricky.
    Awesome, exactly what I was looking for. Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •