Doing it with style
No doubt you have all seen form fields which contain prompts for the required inputs, and the prompts are removed when you enter the inputs. Also the prompts return if you leave the input without entering any text.
In all the forms that I have seen this is done using jQuery/javascript. So I thought that it might be interesting if this were done using just CSS. So I have produced the demo form above.
If you click on any label or input the input prompts will be removed so that you can enter text. If you enter your text then click another field the promt for the entered field will not return. However, if you go back into the same field and delete your text then leave this field the prompt will be displayed.
As an added bonus the prompt text can be a different color to the input text.
All done with just CSS and works in all the latest browsers.
March 2015 - With the latest CSS placeholder and pattern style this will soon be redundant.
Because of all the time and effort spent in producing this demonstration I would ask that you respect my copyright.
Your donations keep CSS PLAY running.
If your donation is for the use of a demo then please email me with the demo url after making your donation.