Stylizing input element is a common task for us as a web developer, we can make it look nicer by putting stylized input image (color gradient, smooth border, box shadow, etc) as an input background. Nice but the images also take some of our bandwidth, thankfully CSS3 adds some support for element styling, so we can replace them with only CSS.
The Needs and The Basic
While developing web apps I always meet a task to create some input forms, using default input without any style will ruin my web apps theme thus I always styling them. The common way to styling an input element is by putting an image as an input background and then positioning the background properly. Take a look at following example :

Photoshop Effect vs CSS3 Properties
At above example, the image is only using some Photoshop technique : color gradient, stroke and drop shadow. Rather than take some time creating images, we can stylize them using only CSS. For replacing the Photoshop techniques we can use CSS3 properties :
- Color Gradient replace with -webkit-gradient or -moz-linear-gradient property.
- Stroke replace with border property.
- Drop Shadow replace with -webkit-box-shadow, -moz-box-shadow or box-shadow property.
- For rounded corner we can use -webkit-boder-radius, -moz-border-radius or boder-radius property.
Step By Step Styling Them
First we create the default input element using HTML.
<input name="sample" type="text" size="40" />

Add some styling for the text effect : padding, font-size, and text-shadow.
input { padding: 5px; font-size: 15px; text-shadow: 0px 1px 0px #fff; }

Manipulate the input background with linear gradient with starting color with grey (#bcbcbe) and ending color with white (#ffffff).
input { padding: 5px; font-size: 15px; text-shadow: 0px 1px 0px #fff; outline: none; background: -webkit-gradient(linear, left top, left bottom, from(#bcbcbe), to(#ffffff)); background: -moz-linear-gradient(top, #bcbcbe, #ffffff); }

To make the input rounded and having a stroke effect we set its border radius with 3pixels and border thickness with 1pixels using darker grey color (#717171).
input { padding: 5px; font-size: 15px; text-shadow: 0px 1px 0px #fff; outline: none; background: -webkit-gradient(linear, left top, left bottom, from(#bcbcbe), to(#ffffff)); background: -moz-linear-gradient(top, #bcbcbe, #ffffff); -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; border: 1px solid #717171; }

Now add drop shadow effect by setting box-shadow property with 1pixels distance on the right and 1pixels distance on the bottom, set 0 for shadow blur and white (#ffffff) for the shadow color.
input { padding: 5px; font-size: 15px; text-shadow: 0px 1px 0px #fff; outline: none; background: -webkit-gradient(linear, left top, left bottom, from(#bcbcbe), to(#ffffff)); background: -moz-linear-gradient(top, #bcbcbe, #ffffff); -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; border: 1px solid #717171; -webkit-box-shadow: 1px 1px 0px #efefef; -moz-box-shadow: 1px 1px 0px #efefef; box-shadow: 1px 1px 0px #efefef; }

If the input has focus state we add a box shadow effect like Safari, we just need to set the box-shadow property with 0pixels distance on the left and on the bottom, set 5pixels for shadow blur and light blue (#007eff) for the shadow color. This will make a similar effect like Photohop’s Outer Glow effect.
input:focus { -webkit-box-shadow: 0px 0px 5px #007eff; -moz-box-shadow: 0px 0px 5px #007eff; box-shadow: 0px 0px 5px #007eff; }

Conclusion
We have stylizing our default input until it’s similar to the input with image background. Don’t forget to take advantages of CSS3 for replacing image usage. Ok, that’s it and thanks for reading!
Stylize Input Element Using CSS3 (via @hdytsgt)
[Community News] jQuery Fundamentals
RGraph : HTML5 Canvas Graph Library
jQuery Plugin : jQuery iPhone UI
Pikachoose : Another jQuery Plugin for Image Gallery
HTML5 Security Cheatsheet
[Community News] How to turn any jQuery plugin into a Wordpress one
Zoom Your Element Using Zoomooz.js
[Community News] Build a Flash-like Game With Scripty2
[Community News] CSS3 Transitions available on Firefox 3.7
[Community News] CSS from the Ground Up
- How To Create iPhone-Style Navigation (Part I)
This post has got 23 shouts so far - jQuery Plugin : jConfirmAction
This post has got 34 shouts so far - iPhone-Style Navigation:AJAX + Rotate (Part II)
This post has got 12 shouts so far - Simple Flip Puzzle Effect with jQuery
This post has got 6 shouts so far - Howto Create Mac-like Login Form
This post has got 7 shouts so far - Implement Password Strength Meter & Gauge.js
This post has got 8 shouts so far - Stylize Your Own Checkboxes
This post has got 15 shouts so far - Create Animated Navigation Menu From Stratch
This post has got 7 shouts so far
- showing database connection error… to check...
by melwyn on Pikachoose : Another jQuery Plugin for Image Gallery - Great article! I’m from Brazil, I’ve been following your...
by Thiago on [CodeSnippet] CSS3 Flying Menu - Looks nice
by TheShadow on Filter Image View Using jQuery - Nice drop down menu tutorial.
by TheShadow on Simple CSS3 Dropdown Menu - love your site
by eJobsViet on Free Web UI Element Pack




Beben
kayak komentar ini nih ada stylize inputnya yah…xixixixi
Stylize Input Element Using CSS3 | RefreshTheNet
[...] Stylize Input Element Using CSS3 | Webstuffshare.com — Worth Sharing Bookmarked Webstuff [...]
[Linkdump #2] CSS3 na koniec tygodnia. « Tomasz Kowalczyk
[...] jak zrobić ładne pole tekstowe, to zapraszam do zapoznania się z poniższym artykułem. | Artykuł [...]
Top Worthwhile Tutorials of the Week – #5 | AEXT.NET MAGAZINE
[...] Stylize Input Element Using CSS3 [...]
Lee Fuller
Great tutorial.
he wonders of CSS3, been trying to figure out how to do something like this for a while now, thank you for sharing.
robpane
yeow… thanks a lot… I hoope you wouldn’t mind, i’ll use it to my site…
waladi abdauh
dahsyat kaka..!
Anonymous Coward
You can actually add a filter to make this work in IE5 and up:
input {filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#bcbcbe, endColorstr=#FFFFFF);}
[User Link:Stylize Input Element Using CSS3] | Tips for Designers and Developers | tripwire magazine
[...] Stylize Input Element Using CSS3 [...]
Snegurka
very useful article, thanks
Ladiesman217
Kalo di IE gag ada ya propertis gradiasinya ?
CSS Brigit | Stylize Input Element Using CSS3
Stylize Input Element Using CSS3…
Stylizing input element is a common task for us as a web developer, we can make it look nicer by putting stylized input image (color gradient, smooth border, box shadow, etc) as an input background. …
190+ Useful Fresh Articles for Web Designers | tripwire magazine
[...] Stylize Input Element Using CSS3 [...]
14 Best Fresh CSS3 Tutorials
[...] Stylize Input Element Using CSS3 [...]
Hidayat Sagita
@Ladiesman217 : Memang tidak dibuat hack untuk IE-nya
Rendicahya
siiip saya cari2 cara bikin textfield yg kayak di twitter, ternyata ketemu disini jg.
makin sip nih blog!
thanks!
Hidayat Sagita
@Rendicahya Alhamdulillah klo bermanfaat
required
firefox, safari, chrome
IE, opera
Boubakr Nour
Very useful tutorial… Thank’s
Sunny
Nice work! Thanks for sharing. But, this styling doesn’t work in IE. How can I make it work in IE also? Please help me to do it in IE too.