Styling HTML Submit Buttons

About Us

SEO Web Tips is a regularly updated blog providing search engine optimization tips, tricks and tutorials. We hope you will find many useful web design and development ideas here as well. Thanks for dropping by and please consider subscribing to our blog feed or better subscribing by email for daily updates. More »




Styling HTML Submit Buttons

Lately I have been coding few website including many HTML forms and I found out that various browsers will render HTML submit button quite differently. I will show you how to properly style submit buttons in order to achieve a very similar look in all major browsers. First, bellow is a basic HTML submit button markup.

<input type="submit" name="submit" value="Submit" class="submit" />

First thing I did was to set a small padding on sides of the button to make it look better, leaving a default browser button look. I have also changed the default cursor when pointing on a submit button. Bellow is the corresponding part of the stylesheet.

.submit {
  cursor:pointer;
  padding:1px 5px;
  }


Here is how our HTML submit button looks in different browsers so far (all used browsers were clean installations without any widgets, plugins or add-ons):

HTML Submit Buttons
As you can see, Firefox 3.0 and Opera 9.5 render the button pretty good, Internet Explorer 7 does not. IE7 adds too much padding to the left and right side, making the submit button look ugly. It’s a well-known IE width bug (present in both IE6 and IE7), easy to fix though. Let’s edit the stylesheet.

.submit {
  cursor:pointer;
  overflow:visible; /* ie6/7 width fix */
  width:auto; /* ie6/7 width fix */
  padding:1px 5px;
  }


HTML Submit Buttons 2
Looks much better now. Next thing I wanted to do was to achieve exactly the same look in all three browsers. Let’s add some border and background color.

.submit {
  cursor:pointer;
  overflow:visible; /* ie6/7 width fix */
  width:auto; /* ie6/7 width fix */
  padding:1px 5px;
  background:#ddd;
  border:1px solid #aaa;
  }


HTML Submit Buttons 3
As you can see, our HTML submit button is already looking fairly similar in all three browsers. Finally, let’s define a color and font for the submit button value.

.submit {
  cursor:pointer;
  overflow:visible; /* ie6/7 width fix */
  width:auto; /* ie6/7 width fix */
  padding:1px 5px;
  background:#ddd;
  color:#333;
  font:10pt arial, sans-serif;
  border:1px solid #aaa;
  }


HTML Submit Buttons 4
That’s it. Probably the closest look possible to achieve. They are still not the same though. Especially the one in IE, which has too much top and bottom padding. I haven’t yet figured how to fix that. Once I figure it out, I will update this post. If it really bothers you, you can still use Internet Explorer conditional comments and reset the padding just for Internet Explorer.

  1. greg Says:   

    Well another approach would be to use the button element instead of just input

    <button type="submit">Submit</button>

    this way you can style it individually & get it to look 100% across all browsers, you can also go as far as having an image in there etc. (button) is way more flexible.

  2. admin Says:   

    Yep. I have totally forgot about that approach. Thanks for the tip.

  3. Geoserv Says:   

    I only recently started styleing my forms and I have been looking for cross browser button codes, thanks for the post and thanks for the tip greg.

  4. Garden flags Says:   

    govind221817@gmail.com

  5. Findlay Says:   

    The IE width issue was one I have been trying to solve for a while now.
    Thank you for providing the solution!

  6. Web design Company Says:   

    Styling buttons using CSS is good and can achieve professional results. However in my experience, using image as the form button provides many more possibilities and can lead to design of creative buttons that cannot be easily achieved by styling standard form buttons.

  7. Misura Says:   

    @Web design Company, using an image is nice but doesn’t work well for dynamic and site-wide styling of input buttons.

    @author, thanks for the tips!

  8. Jess SEO Says:   

    @web design company, I am totally agree with you. I always design new HTML submit buttons because is more attractive to my visitors. thank you for the posting.

  9. Toronto Web Design Says:   

    Buttons are great and can achieve professional outcome. In my past experience using image as theprovides many more possibilities and can lead to lots of creative buttons that cannot be easily achieved by styling standard HTML.

Name (required) 
Email (required) (will not be published) 
Website 
Comment (all comments will be manually reviewed before approval)