Search code examples
htmlformslabelplaceholder

How to create a label inside an <input> element?


I would like to insert a descriptive text inside an input element that disappers when the user click on it.

I know it is a very common trick, but I do not know how to do that..

What is the simplest/better solution?


Solution

  • <input name="searchbox" onfocus="if (this.value=='search') this.value = ''" type="text" value="search">
    

    A better example would be the SO search button! That's where I got this code from. Viewing page source is a valuable tool.