Creating Styled Submit Buttons

by Darren Hedlund
Microcyb.com
Wednesday, 23rd November 2005

Adding a Style to the Submit Button

Submit buttons are gray, right? Well not necessarily. Of course you can just replace the standard form button with an image, but using CSS will give you a nice effect without the need to create and load an image, however small.

The HTML for a form button looks like this:

<input type="submit" value="Submit">

The part of that to which we will add the style is the 'input', this is called the selector for our style. Since we are going to make the button red we will call the style class we add 'red', it could be called anything but for clarity it is a good idea to call classes names that will mean something to you.

So, the style is added by creating a class of 'input' and adding some style properties to it. Specifically we will add a red background color to the button:

input.red {background-color: #cc0000;}


To make this readable as a style sheet it needs to have style tags surrounding it:

<style type=text/css>
input.red {background-color: #cc0000;}
</style>


Copy this style sheet and paste it before the </head> tag of your page.

Then find the HTML that makes the button:

<input type="submit" value="Submit">

 and alter it to read:

<input class="red" type="submit" value="Submit">


and you should have a nice red button for your form. 


However the black text is not too clear on that button, so let's add a little more to the style definition to make it look crisper:

<style tyle=text/css>
input.red {background-color: #cc0000; font-weight: bold; font-size: 12px; color: white;}
</style>


This will give you a red button with bold white text on it. Of course



Options:
Printer Friendly
Email Friend

About The Author:

Darren Hedlund is a freelance Web developer, writer, and data analyst. Darren has a graduate degree in Computer Information Science and has spent the last 15 years developing application and environments from hand held, windows, web, virtual science, gaming, artificial intelligence and graphics design. Darren's coding knowledge ranges from C+, Visual Basic, .NET, PHP, JSP, REXX, KIXX, and many others. His graphical and environmental knowledge stems in Macromedia Flash, 3D studio Max, Curious Labs Poser, Adobe Photoshop, and many others. Darren works in many platforms ranging from database, visual design, and, system development.

Developer Categories



Developer Tutorials
ASP
CGI & Perl
CSS
Flash
HTML
Java
JavaScript
MySQL
PHP
Python
XML

Developer Documentation

Developer Tools



Search our Developer Tutorials
  The DevSyndicate Network