SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: button vs input

  1. #1
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,734
    Mentioned
    31 Post(s)
    Tagged
    1 Thread(s)

    button vs input

    I am curious, what is the considered best practice for using the <input type='button'> vs <button type='button'> on a form. Is there an advantage of using one over the other.. does each have some sort of semantic meaning, or is one easier to style than the other???

    the wisdom of the experts is much appreciated.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,604
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Using <button> allows you to use HTML to define the button content whereas using <input type="button"> doesn't.

    For example:

    <button>Press <strong>here</strong>.</button>

    as compared to

    <input type="button" value="Press here.">
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,734
    Mentioned
    31 Post(s)
    Tagged
    1 Thread(s)
    is that the only difference? no behavioral change or semantic meaning? is it poor form ( no pun) to use buttons as ... well, buttons... for example in a dynamic form when you are addig/revealing or hiding fields... I am tempted to use buttons (and by extension wondered about input type button) when providing a user with an interface to hide /show/add/remove fields in a form....


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
  •