First, you need to understand that two different implementations are in use. They are pseudo-classes and pseudo-elements.
Now, that you are aware of the types of implementation, let’s go through the code.
::-webkit-input-placeholder { /* WebKit, Blink, Edge */ color: #0000ff; } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #0000ff; opacity: 1; } ::-moz-placeholder { /* Mozilla Firefox 19+ */ color: #0000ff; opacity: 1; } :-ms-input-placeholder { /* Internet Explorer 10-11 */ color: #0000ff; }
The above code will enable you to color the input’s HTML5 placeholder. For each browser, there is a different implementation. For example,
All the above pseudo-classes and pseudo-elements are necessary to handle the required result.
Also, you need to make sure that the selectors are kept separately. The reason is simple: If any one of the selectors is invalid, it will make the group invalid as well, making your code unusable.
There are some special cases that you need to make sure don’t happen.
To understand the whole concept, you can watch it live here. The code is put together by Sk8erPeter.
Do you have anything to add to the tutorial? If yes, don’t forget to use the comments section below.
You can also check on our website for videos about HTML/CSS. Below are some examples:
You can also follow some of our broadcasters who program in JavaScript as below:
Another cool way to find out interesting things about HTML/CSS is to access our project page!
We’re thrilled to announce an exciting opportunity for you to win not one but two…
Acquiring practical skills is crucial for career advancement and personal growth. Education Ecosystem stands out…
Artificial Intelligence (AI) has been making significant strides in various industries, and the software development…
Another week to bring you the top yield platforms for three of the most prominent…
If you hold a large volume of LEDU tokens above 1 million units and wish…
It’s another week and like always we have to explore the top yield platforms for…
View Comments
Working with HTML5 placeholders is not easy at all. There are different implementation for different browsers which makes life of web developers harder as usual. Great guide, btw!