0

I know I can make a input form with default text by specifying the value attribute, but how do I make it so the text is transparent visually and also disappears when it is clicked? I want to make my text fields the way twitter does it.

All the resources I find seem overly complex and I would expect this to be as simple as setting a few attributes, but I just don't know which ones to set. I tried looking at twitters source code in chrome dev tools but I couldn't locate the code which enabled them to use transparent text that disappears when clicked.

chopper draw lion4
  • 12,401
  • 13
  • 53
  • 100
  • 6
    You mean the [placeholder](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-placeholder) attribute? – j08691 Jul 13 '14 at 16:17

2 Answers2

3

You can use placeholder attribute for HTML5 supported browsers. E.g.:

<input type="text" placeholder="First name">

For old browsers, it is not a trivial thing to implement. Please see these questions:

Community
  • 1
  • 1
sampathsris
  • 21,564
  • 12
  • 71
  • 98
1

Try the placeholder attribute:

<input type="text" placeholder="Name">
Robbin Benard
  • 1,542
  • 11
  • 15