2

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 2

4

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>

1
  • 1
    Universe heard your voice :(
    – Rahul
    Aug 18, 2021 at 11:23
3

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" />
3
  • 1
    When you answer first, give two examples, but the vote goes to someone else. Well... xD
    – Hassen Ch.
    Aug 18, 2021 at 11:03
  • 1
    Please do not play victim card :p @HassenCh.
    – Rahul
    Aug 18, 2021 at 11:10
  • 1
    @HassenCh. Sorry mate, I’ll give that vote to you. :)
    – user16620643
    Aug 18, 2021 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.