We already know that CSS3 has the ability to create a lot of new possibilities to design and implement better web forms. Also, HTML5 has its important role when it comes about creating more usable forms, without actually needing any Javascript code.
Knowing that, check out the below preview to see the login form we’re going to create in this article:

Markup
<form id="login">
<h1>Log In</h1>
<fieldset id="inputs">
<input id="username" type="text" placeholder="Username" autofocus required>
<input id="password" type="password" placeholder="Password" required>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="Log in">
<a href="">Forgot your password?</a><a href="">Register</a>
</fieldset>
</form>
The HTML5 stuff
New HTML5 attributes descriptions, according to latest specifications:
- placeholder – A short hint (one word or a short phrase) intended to aid the user when entering data into the control represented by its element.
- required – Specifies that the element is a required part of form submission.
- autofocus – Specifies that the element represents a control to which a UA is meant to give focus as soon as the document is loaded.
- type=”password” – Specifies that its input element is a one-line plain-text edit control for entering a password. (not HTML5 specific)
The CSS
For this article, I will not paste the whole lines here. Instead, I’ll just add the ones who help creating some cool effects.
Paper stack effect
Box-shadow will help us creating this nice effect by defining multiple shadows that actually overlap.

#login
{
box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, .2),
0 3px 0 #fff,
0 4px 0 rgba(0, 0, 0, .2),
0 6px 0 #fff,
0 7px 0 rgba(0, 0, 0, .2);
}
Stitch effect
This effect is added using pseudo-elements. Using pseudo-elements helps you avoid extra markup and this is a perfect example: keep the markup clean and let the CSS do the magic.

#login
{
position: absolute;
z-index: 0;
}
#login:before
{
content: '';
position: absolute;
z-index: -1;
border: 1px dashed #ccc;
top: 5px;
bottom: 5px;
left: 5px;
right: 5px;
-moz-box-shadow: 0 0 0 1px #fff;
-webkit-box-shadow: 0 0 0 1px #fff;
box-shadow: 0 0 0 1px #fff;
}
Styles excerpt.
Subtle gradient lines
I’ve first seen this effect on Gene Locklin‘s page and I thought this is pretty cool. So, I decided to use it for highlighting the “Log in” heading. Using pseudo-elements (again) and CSS3 gradients some cool lines are added to simulate a strikeout effect.

h1
{
text-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0px 2px 0 rgba(0, 0, 0, .5);
text-transform: uppercase;
text-align: center;
color: #666;
margin: 0 0 30px 0;
letter-spacing: 4px;
font: normal 26px/1 Verdana, Helvetica;
position: relative;
}
h1:after, h1:before
{
background-color: #777;
content: "";
height: 1px;
position: absolute;
top: 15px;
width: 120px;
}
h1:after
{
background-image: -webkit-gradient(linear, left top, right top, from(#777), to(#fff));
background-image: -webkit-linear-gradient(left, #777, #fff);
background-image: -moz-linear-gradient(left, #777, #fff);
background-image: -ms-linear-gradient(left, #777, #fff);
background-image: -o-linear-gradient(left, #777, #fff);
background-image: linear-gradient(left, #777, #fff);
right: 0;
}
h1:before
{
background-image: -webkit-gradient(linear, right top, left top, from(#777), to(#fff));
background-image: -webkit-linear-gradient(right, #777, #fff);
background-image: -moz-linear-gradient(right, #777, #fff);
background-image: -ms-linear-gradient(right, #777, #fff);
background-image: -o-linear-gradient(right, #777, #fff);
background-image: linear-gradient(right, #777, #fff);
left: 0;
}
The final result
Using the above techniques, here’s the final result:
Conclusion
This login form looks very well also on older browsers, as you can see below:

Internet Explorer 8 screenshot.
As a future improvement, you can add also HTML5 placeholder fallback as you have seen in one of my previous articles.




I liked the Gene Locklin‘s effect. Nice work Catalin, as always!
Nice tutorial, will be saved under bookmarks.
Great article. Forms looking alot more exciting now!
Nice button
Thanks guys, nice to hear you like it!
DUDE u are incredible.. This site is the best CSS3 site on the web
:) thanks Simon, I’m glad you like my CSS3 tutorials.
Pretty cool. nice work :)
Thanks Pedro ;)
It is cool. A note: type=”password” is not html5 specific.
Yep, type=”password” is not HTML5 specific. Thanks for pointing that!
That is one great form. Good job.
Thanks Jake, I’m glad you like it!
I would love to use it, or a variation of it, on my new site. If that option is available, what would you charge to help me modify it. It would need a matching dropdown.
Jake, you can use this or your website, with or without attribution.
Though, a link back will be always appreciated ;)
Really Cool! i loved it! so many interesting techniques here, thank you so much!
Regards!
Thanks Guilherme, don’t forget to subscribe to RSS feed! :)
Hello I want to use your page effect in my website but I used a grid framework. Can we use this css3 style without position:absolute ? Because when I delete this I don’t have the style.
Thanks
Jonathan, the
position:absolutefor the#loginis only to center the form vertically and horizontally.If you don’t need that, just replace it with
position:relativeto avoid any problems.Hi,
great tutorial :)
I have one question: how to get this effect?
http://oi40.tinypic.com/sv71q9.jpg
Marcin, that behavior is caused by the
requiredHTML5 attribute. Please check above for the markup.Thanks for your comment.
OK, thanks :)
RedTeamDesign has already added to RSS reader :)
Greetings from Polish;)
Hello:
Nice work I like it. So I have one question, You have more icons like the inputs icons?
Thank you
Steven, that might be a good suggestion.
Perhaps one of my future articles will contain some freebies like icons. Stay tuned!
Ok, and thanks again.
how do i change the “Please fill out this field” ? where is it defined?
Jay, that message is generated by the new HTML5
requiredattribute. This is not customizable and it’s specific to the browser.As an alternative, you can always try :http://docs.jquery.com/Plugins/validation