The goal of this post is to harness some new functionality provided by CSS3 and move away from images. We are going to create a CSS3 login form without images yet still have a visually pleasing result.
Writing the HTML
First lets begin with creating the HTML markup that makes up the login form. Start with the basic HTML page as I will not include that portion in the code.
<form> <label>Username:</label> <input type="text" name="username" /> <label>Password:</label> <input type="password" name="password" /> <input type="submit" value="Submit" name="submit" class="submit" /> </form>
This is the basic markup with a few labels and Input elements. Now there are many different ways to markup the HTML you see above, but I tried to make it as simple as possible. Make sure you add the Class SUBMIT to your button because it will require different styling.
HTML Only Demo
As you can see above we really need the power of CSS in order to give this login form some visual appeal. Enter CSS3!
Writing the CSS
It is now time to give this login form some life. CSS3 has some really powerful new features and we will be covering only a few of them. First lets get some of the basic layout styles down nothing having to do with CSS3
Styling the Form Element
We will begin writing our CSS targeting the form element as some of the other elements on the page will rely on the parent element. I’m going to go through the properties in logical order not in alphabetical order. We want to set the width to 250px with 20px of padding on all sides and a 1px border also.
form {
width: 250px;
padding: 20px;
border: 1px solid #270644;
}
Adding CSS3 to the Form Element
Now lets add in the CSS3 magic to bring this form to life.
form {
width: 250px;
padding: 20px;
border: 1px solid #270644;
/*** Adding in CSS3 ***/
/*** Rounded Corners ***/
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
/*** Background Gradient - 2 declarations one for Firefox and one for Webkit ***/
background: -moz-linear-gradient(19% 75% 90deg,#4E0085, #963AD6);
background:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#963AD6), to(#4E0085));
/*** Shadow behind the box ***/
-moz-box-shadow:0px -5px 300px #270644;
-webkit-box-shadow:0px -5px 300px #270644;
}
Styling the Input Elements
Styling the input elements is pretty easy but it does have some complications that can frustrate. We will apply a background color, a top border, some padding, and a width.
input {
width: 230px;
background: #8a33c6;
padding: 6px;
margin-bottom: 10px;
border-top: 1px solid #ad64e0;
border-left: 0px;
border-right: 0px;
border-bottom: 0px;
}
Adding CSS3 to the Input Element
For the input element we will implement the new features of CSS3 called transitions. Unfortunately this only works in Webkit browsers such as Safari and Chrome.
input {
width: 230px;
background: #8a33c6;
padding: 6px;
margin-bottom: 10px;
border-top: 1px solid #ad64e0;
border-left: 0px;
border-right: 0px;
border-bottom: 0px;
/*** Adding CSS3 ***/
/*** Transition Selectors - What properties to animate and how long ***/
-webkit-transition-property: -webkit-box-shadow, background;
-webkit-transition-duration: 0.25s;
/*** Adding a small shadow ***/
-moz-box-shadow: 0px 0px 2px #000;
-webkit-box-shadow: 0px 0px 2px #000;
}
Now that we have the styles for the inputs in place lets style the hover events for those same inputs.
input:hover {
-webkit-box-shadow: 0px 0px 4px #000;
background: #9d39e1;
}
Some of you may not have caught it but I increased the radius of the shadow on hover from 2px to 4px. That is why we used the transition effects on the inputs because it triggers that change on hover.
Styling the Button
Ok we’re almost done, on to the button! Since we gave our button the class SUBMIT we can use that selector in our CSS.
input.submit {
width: 100px;
color: #fff;
text-transform: uppercase;
text-shadow: #000 1px 1px;
border-top: 1px solid #ad64e0;
margin-top: 10px;
}
Adding CSS3 to the Submit Button
input.submit {
width: 100px;
color: #fff;
text-transform: uppercase;
text-shadow: #000 1px 1px;
border-top: 1px solid #ad64e0;
margin-top: 10px;
/*** Adding CSS3 Gradients ***/
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#963AD6), to(#781bb9));
background: -moz-linear-gradient(19% 75% 90deg,#781bb9, #963AD6);
}
That’s it! Now you have an awesome login form styled strictly with CSS3 and no images. Of course it only works in webkit browsers currently which are Safari and Chrome, but CSS3 support will be coming to a browser near you soon. If you liked this post please promote it below!









May 10th, 2010 at 12:57 pm
This is so awesome, simple but creative.
May 10th, 2010 at 4:12 pm
Thanks, I’m just beginning to learn CSS3. It is so powerful!
May 10th, 2010 at 11:49 pm
Gradients make my head hurt.
Tony´s last blog ..WordCamp SF 2010: The Only Recap That Matters
May 11th, 2010 at 1:59 am
Simply elegant……. thanks a lot for share
May 11th, 2010 at 7:46 am
Very nice, but for a better conversionrate I would design the submit-button in different colors that the other form-elements.
Webstandard-Blog´s last blog ..Ladezeit von Webseiten verbessern – Bilder mit Dateikomprimierung optimieren
May 12th, 2010 at 9:51 am
Nice one! I did one too! http://bbxdesign.com/wp-content/uploads/html/formulaire-css3.html
May 18th, 2010 at 10:37 am
It is awesome in Chrome, in safari it is good. in Firefox and opera transition effect is not working that much good so average in that.. and In IE …………. you people know what it is.
May 23rd, 2010 at 5:59 am
Very nice, but you did forgot 1 thing:
Whenever you do something with CSS3 you should use not only browser specific (-webkit, -moz) declarations, but also standart CSS3 declarations like border-radius (http://www.w3.org/TR/css3-background/#the-border-radius) and box-shadow (it has been removed from CSS3, but in my opinion you should use it anyway, i think Opera and some other browsers are implementing this)
CSS3 has nothing on gradients, but there is IE filter which could do the trick in IE: filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=’#f88e11′, endColorstr=’#f06015′);
May 24th, 2010 at 10:27 am
Excellent article…Thanks to you and comments from Valentine too..If you get time please, update this with non css3 supported browser also.
Thanks
Ashfaq
May 24th, 2010 at 3:45 pm
Ashfaq, there’s no point to implement this for non-CSS3 browsers. Graceful degradation is what you should look for. That means IE user will get square corners instead of rounded and regular background instead of gradient. But it’s still good and beatufilul check it out yourself with IE. And it’s a good practice!
May 25th, 2010 at 10:28 am
Awesome Post, Very Detailed Explanation On CSS3 Styling… Thanks
Aafrin´s last blog ..A Noob’s Guide To Set Yii Php Framework In Windows Environment – Part 2
May 28th, 2010 at 8:45 am
Whoa! I didnt know I could do this much with CSS and HTML! Thanks for writting such an amazing piece of tutorial. I am gonna need this. Can I add this article to my CSS aggregator site ?
October 6th, 2010 at 8:15 am
thank you for the tutorial…
I’ll use this tutorial for the essential of my programs…
October 24th, 2010 at 9:26 am
You can get rid of the background bleed at the bottom of the rounded corners with:
background-clip: padding-box;
or
-webkit-background-clip: padding;
-moz-background-clip: padding;
Note that the vendor prefixed properties have no “-box” at the end.
Source:
http://stackoverflow.com/questions/2394249/parts-of-background-image-visible-when-using-border-radius
https://developer.mozilla.org/en/CSS/background-clip#Browser_compatibility
Lachlan´s last blog ..YouTube Downloader Bookmarklet Update v21
November 22nd, 2010 at 10:54 am
It does work in Google Chrome but not in IE8 and IE9 Beta
November 23rd, 2010 at 9:02 pm
I’ve tried it as well, it works fine on Firefox, but not with IE 7

Amr Boghdady´s last blog ..Deutschedcom Launched !
December 10th, 2010 at 8:48 pm
This is the most awesome tutorial I’ve ever found. Nice work man.
December 29th, 2010 at 6:07 am
Great butt not supported less versions of ie and firefox
February 16th, 2011 at 9:05 am
this form is beautiful!
March 3rd, 2011 at 6:38 am
Hey Shane,
Where did you originally learn your CSS3 skills? You do some killer stuff. I’m struggling to get going myself. Thanks!
April 19th, 2011 at 6:41 am
Great! Yeah i manage to do this myself, but never doubt your coding format and color combinations look better. Do continue posts like this again. Thanks!
April 27th, 2011 at 12:11 pm
Hi
Thanks a lot.
very beauty FORM.
I use it in our site.
July 12th, 2011 at 8:59 pm
amazing tutorial and work ! thank you
August 3rd, 2011 at 12:53 pm
If you have ever seen the new twitter.com login form you can see this cool effect. This is a good tutorial trying to recreate that style form. The markup is simple enough.
August 23rd, 2011 at 11:09 pm
Great stuff! For too long the web has been tainted with ugly forms!
September 16th, 2011 at 1:17 am
Hi shane!! your the master of tutorial!! love it! thanks for sharing!
Nova´s last blog ..Inexpensive Car Insurance