Style a login form
The look is so important for a form. Unfortunately almost all forms look so boring and standard. Luckily it is pretty easy to style a login form with css.
The old way…
Login forms are pretty usual at web sites, but they are very often very bad looking… This is a good example on a standard way to do a login form. (Don’t worry, we will make this form look better soon…)

This is the HTML code for this form:
<form id=”login”><br />
Username: <input type=”text” name=”user” /><br />
Password: <input type=”password” name=”password” /><br />
<input type=”submit” value=”Submit” name=”Submit” /><br />
</form>
It doesn’t look that sexy, right?! ![]()
And it often look like this when you login at sites…
We make it look better
A simple thing is to put the form on one row, like this:
![]()
What we did to create this is simply remove the <br> after the input’s.
Starting to look a little bit better, but still extremely boring right…
What about a little color and stuff like this?
![]()
Nothing hard, but it directly looks so much better.
To do this, change the style sheet into this:
#login {
background-color: #DDDDDD;
color: #000000;
border: 1px solid #777777;
font-family: Verdana;
font-size: 10px;
text-align: right;
width: 440px;
margin: 2px;
}
This styles the form that we created, because it has id=”login”.
It should be pretty obvious what it does, so just read the stylesheet.
The next thing we do is style the inputs and the submit button with this style sheet:
#login .theInput {
font-family: Verdana;
font-size: 11px;
width: 110px;
margin-right: 5px;
}
#login .theSubmit {
font-family: Verdana;
font-size: 10px;
background-color: #333333;
color: #FFFFFF;
margin-right: 5px;
}
And make some small changes to the html, adding classes to the inputs and button:
<form id=”login”> Username: <input type=”text” class=”theInput” name=”user” />
Password: <input type=”password” class=”theInput” name=”password” />
<input type=”submit” name=”Submit” value=”Submit” />
</form>
The result looks like this:
![]()
It’s beautiful right
There are so many more things you can do, but start playing around with this form and create your own designs. Small things like changing the standard text fonts and sizes make big differences. It directly looks more professional. You can also replace the submit button with an image for creating even more unique design.
Until next time… happy form-ing!

May 11th, 2009 at 9:35 am
Thanks
May 11th, 2009 at 3:51 pm
You’re most welcome! Feel free to request tutorials you want us to publish!
May 23rd, 2009 at 3:08 pm
Hi, nice posts there
thank’s for the interesting information
May 24th, 2009 at 12:03 pm
Hi, thanks for the great tutorial, i would like to know if i want to put the username and password letters above the input fields, like this:
Username Password
[ ] [ ] [Login]
How can i do this?
June 3rd, 2009 at 2:04 pm
I’ll see if we can possible create a tutorial about that also soon…
June 10th, 2009 at 4:33 pm
Looks like the submit button class name is missing from the input tag in your final html code example. Should be: