Placeholder styling css. The appearance of the field names or how to change the placeholder

If you're not familiar with the placeholder attribute, let's explain a bit what it is and where it's used. It is used in form input fields. The attribute displays an inscription in the input field, representing the role of a hint. Earlier on our site there was an example with using javascript, positive side this method it's cross browser. Now let's talk about styling the placeholder attribute, which is used on the input and textarea elements.
The code for the input field in our example would look something like this:

At the output, we get the following field:

Now let's imagine that we need to style the placeholder, for this we need to write a set of rules in CSS:

::-webkit-input-placeholder ( color: #c1c1c1; ) ::-moz-placeholder ( color: #c1c1c1; ) /* Firefox 19+ */ :-moz-placeholder ( color: #c1c1c1; ) /* Firefox 18- */ :-ms-input-placeholder ( color: #c1c1c1; )

We get:

We can not change all properties, but a list of most of them supported by modern browsers is given below:
font(also related properties)
background(also related properties)
color
word-spacing
letter spacing
text-decoration
vertical-align
text-transform
line-height
text indent
text overflow
opacity

AT different browsers the rule is written differently, because as long as there is no single standard, this set of records continues to be relevant. In the IE browser, as well as firefox below version 18, placeholder is perceived as a pseudo-class, and in the new firefox browsers, webkit and blink are treated as pseudo-elements.

Shorten text in placeholder
Sometimes hints can be so long that they cannot fully fit into the input field. For these purposes, you can also use additional properties that will shorten the placeholder text in the input field.

Input ( text-overflow:ellipsis; ) input::-moz-placeholder ( text-overflow:ellipsis; ) input:-moz-placeholder ( text-overflow:ellipsis; ) input:-ms-input-placeholder ( text-overflow :ellipsis; )

As a result, we get an input field with a placeholder like this:

Hide text on click
By default, each browser interprets the placeholder response differently. In some browsers, it is hidden immediately when you click on the field, in others it is hidden if there is at least one character in the input field. Let's make it so that the text is hidden when clicking on the field, the same in all browsers.

:focus::-webkit-input-placeholder ( color: transparent; ) :focus::-moz-placeholder ( color: transparent; ) :focus:-moz-placeholder ( color: transparent; ) :focus:-ms-input -placeholder (color: transparent; )

We get this action:

In an effort to reduce shape and reduce visual noise, tag designers

Badly

Good

Styling: change color of placeholder CSS

Change input field style with placeholder CSS

Badly

placeholder effect for

The placeholder attribute only works for and