Create beautiful form fields using CSS and images

Web Designers or developers care more for site design, colors, arrangement of the form elements, User Interface etc. rather than designing a cool, pleasant and great looking forms as they give designing form elements as a lowest priority.

CSS Custom Search Box
CSS Custom Search Box

Download the Source Code


Even though very few designers concentrate on form look and feel, in reality it makes a lot of difference in many applications. Few do styling form fields with simple CSS tricks and one thing for sure.. making them browser compatible is a bit tough job!

This tutorial will teach you how to create a good looking rounded corner forms by using the beauty of css and images. This is not confined to just beautifying the search box but this basic tutorial will help you to build custom good looking forms. So, lets play with custom look input fields and buttons with images πŸ™‚

Although there are couple of interesting tutorials all around the web to create good looking forms, this will be a good tutorial for starters or for designers or developers who wants to know on how it works, etc.

Also Read:   CSS and JavaScript Flip effects!

Let’s start to make custom good looking and simple css and image based search box:

1. Create a simple form (HTML) which contains a text input field and a button, below is the code on how it looks like

As you might have observed in the above code you might have a doubt why do we need an DIV with search as an Id? right? – let me clear it, this is just to take the reference of css not to overwrite other form elements if you have many fields in a page. You can have your own div tags and different look n feel for each form elements etc. You can even apply css class, as we gonna make it simple we just avoided all those in the forms and css to reduce the load of HTML form rendering.

2. CSS Style sheet to render the above form

#search {
	font-family:Arial, Helvetica, sans-serif;
	padding:35px 35px;
	border: 1px solid #CCCCCC;
	width: 330px;
	height: 40px;
#search input {
	font-family:Arial, Helvetica, sans-serif;
	background:transparent url(images/bg-search.png) no-repeat scroll 0 0;
	padding:6px 10px 8px 10px;
#search input:focus, #search input:hover, #search button:focus, #search button:hover {
	background:transparent url(images/bg-search.png) no-repeat scroll -312px 0px;
#search button {
	font-family:Arial, Helvetica, sans-serif;
	background:transparent url(images/bg-search.png) no-repeat scroll -202px 0px;
	padding:0px 10px 0px 10px;
	font-weight: bold;
#search button:focus, #search button:hover {
	background:transparent url(images/bg-search.png) no-repeat scroll -514px 0px;

Let me explain the above CSS Stylesheet –
– “#search” makes a simple box around the form you can even avoid this.
– “#search input” refers to the input field within the search id div box. Observed the background? there comes the your own custom image background for the form fields.
– I have used the single image to represent this search box to avoid loading of multiple images either on mouse over or mouse out etc.
– Just played with the position of the image to represent the form elements as you can observe “-312px”, “-202px”, “-514px”, “0px” etc.
– And the rest I think you can change based on the look n feel of your site like font-family, height, width, font-size, color, padding etc.

Also Read:   Create Dynamic Charts using CSS and Javascript with Running-Charts

Summary: Hope you learn few tips from the tutorials, like it? then spread the resource all over the web.

Join thousands of subscribers

And get updates as and when we publish new, informative and research based posts!

Thank you for subscribing.

Something went wrong.

21 thoughts on “Create beautiful form fields using CSS and images”

  1. How about CSS that changes the colour of an inoput box onfocus ?
    I tried one or two but they never work.

    PS if youre so gr8 at CSS why am I typing in a grey font on a grey bkg ?

  2. Adding to the “works in” talks, I tried it in FF3 and it worked great! But in IE 7 when you get to the end of the input field with your typing, the image hangs and pushes left, creating a nasty little eye sore πŸ™

  3. Pingback:
  4. Lol… adding your Google Adsense code inside your demo download (index.html) is not only unprofessional but smells of desperate – it is also against the Adsense TOS

    Perhaps you think you will make money from this scraped content but I think it is too obvious here…

    Thumbs down for you – Unprofessional Amateur!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.