DO YOU NEED A CONTENT WRITER FOR YOUR BUSINESS?

Your One-Stop Solution for All Content Needs! Click here for more!
Css3

HTML5 placeholder color with CSS

Share

Want to change the color of a placeholder of your input fields? Here is an example that helps you to change the color of a placeholder.

Basically, there are three different implementations i.e. pseudo-elements, pseudo-classes, and nothing.

  • WebKit, Blink (Safari, Google Chrome, Opera 15+) and Microsoft Edge are using a pseudo-element: ::-webkit-input-placeholder.
  • Mozilla Firefox 4 to 18 is using a pseudo-class: :-moz-placeholder (one colon).
  • Mozilla Firefox 19+ is using a pseudo-element: ::-moz-placeholder, but the old selector will still work for a while.
  • Internet Explorer 10 and 11 are using a pseudo-class: :-ms-input-placeholder.

Note: Internet Explorer 9 and lower versions does not support the placeholder attribute while Opera 12 and lower do not support any CSS selector for placeholders.

Here is the code for changing color of placeholders:

CSS:
::-webkit-input-placeholder { /* WebKit, Blink, Edge */color:    #FF6550;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */color:    #FF6550;
opacity:  1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */color:    #FF6550;
opacity:  1;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */color:    #FF6550;
}
HTML:
<input name="txt" placeholder="Looks colorful!">
<textarea placeholder="Looks colorful also!"></textarea>

Note to remember that firefox’s placeholder appears to be defaulting with a reduced opacity, so we need to use opacity: 1 here.

CSS Designer

Recent Posts

Writing Tools That Help Content Marketers Produce Cleaner Work

Content marketing has a hidden tax. It's not the writing itself, it's everything that happens…

2 weeks ago

How Data Analytics Is Actually Driving Smarter Marketing Decisions

Most marketing teams aren't failing because they lack data. They're failing because they can't act…

4 weeks ago

The Ultimate SPF Tester Guide: Boost Email Deliverability In Minutes

Email marketing continues to be one of the most effective ways for businesses to communicate,…

4 weeks ago

Sales Ops: A role that helps sales teams work as efficiently as possible

Xerox first introduced it around the mid-1970s. The need came up because the management activities…

1 month ago

Forex Investment Tips for Beginners

Investing in the forex market may look to be a dangerous game. With some worthwhile…

1 month ago

How Did The Restaurant Industry change In Post Pandemic Era?

The coronavirus outbreak has drastically changed the way we live our lives. Yes, that's absolutely…

2 months ago