Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-transform: capitalize; Also affects Placeholder

I have the following simple input.

<input type="text" placeholder="What is your username?" /> 

When I use text-transform: capitalize; to capitalize the first letter of each word, the placeholder also gets capitalized: What Is Your Username?

How can I keep the placeholder intact?

like image 269
Ali Bassam Avatar asked Mar 14 '14 20:03

Ali Bassam


People also ask

Does the text-transform property controls the capitalization of text?

The text-transform property controls capitalization effects of an element's text.

What will happen if you change the font size in the placeholder?

Placeholder styles will not resize an input field and will not affect its box model. Add font-size to your input to fix the placeholder from getting cut off. You also might consider adding placeholder styles for other browsers...

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.

Can you change placeholder with CSS?

<input type="text" placeholder="A red placeholder text..">


1 Answers

You could style the placeholder--

::-webkit-input-placeholder {    text-transform: initial; }  :-moz-placeholder {     text-transform: initial; }  ::-moz-placeholder {      text-transform: initial; }  :-ms-input-placeholder {     text-transform: initial; } 
like image 52
Chad Avatar answered Sep 26 '22 01:09

Chad