Input box grey text

Viewed 225

How can I make an input box have that faint grey text which disappears as soon as you type something into the box.

eg. exists in the ‘Title’ input box when you go to ask a question in the form of ‘Is there an R function for finding the index element in a vector.’.

2 Answers

What you're looking for is called a placeholder. Here is an example:

<input type="text" placeholder="Type something here">

Here is another example with textarea:

<textarea rows="4" cols="50" placeholder="Describe yourself here..."></textarea>

That faint text is called placeholder.

you can have it on your own text field by using 'placeholder' attribute.

<input type="text" placeholder="This is first name" />
Related