Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear HTML5 placeholder attribute text on focus in Chrome

Is there any way I can clear placeholder text on focus in Chrome, Firefox clears the text on focus but Chrome doesn't.

This confuses the user whether the text in the bar is typed, or it's a placeholder text (Even if I changed the text color to light grey), I don't want to use unnecessary JavaScript or jQuery for this, I want to know if there's some HTML/CSS solution for this

Demo Fiddle

Chrome Preview (On Focus)

Chrome Preview On Focus

Firefox Preview (On Focus)

Firefox Preview On Focus

like image 277
Mr. Alien Avatar asked Oct 10 '12 14:10

Mr. Alien


People also ask

How do I change the placeholder text?

The “placeholder” property is used to get or set the placeholder of an input text. This can be used to change the placeholder text to a new one. The element is first selected using a jQuery selector. The new placeholder text can then be assigned to the element's placeholder property.

What is placeholder attribute in html5?

Definition and Usage The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.


1 Answers

Try using

input:focus::-webkit-input-placeholder 
{
    color: transparent;
}

It will resolve the issue. The text is visible on focus because of the auto focus on page load.

like image 193
Shubhanshu Mishra Avatar answered Sep 22 '22 00:09

Shubhanshu Mishra