How to set placeholder value using CSS?

n92 picture n92 · Nov 10, 2011 · Viewed 139.5k times · Source

I want to set the placeholder value of an input box using only CSS and no JavaScript or jQuery.

How can I do this?

Answer

Sarfraz picture Sarfraz · Nov 10, 2011

AFAIK, you can't do it with CSS alone. CSS has content rule but even that can be used to insert content before or after an element using pseudo selectors. You need to resort to javascript for that OR use placeholder attribute if you are using HTML5 as pointed out by @Blender.