How to modify HTML5 input placeholder color

Source: Internet
Author: User

There are three implementations: pseudo-elements (pseudo-elements), pseudo-classes (pseudo-classes), and notihing.
WebKit and Blink (Safari,google Chrome, opera15+) use pseudo-elements

::-webkit-input-placeholder

:-moz-placeholder

::-moz-placeholder

:-ms-input-placeholder

Because each browser has a different CSS selector, you need to do a separate setting for each browser.

1 ::-webkit-input-placeholder{/*WebKit Browsers*/ 2 Color:#999;3}4 :-moz-placeholder{/*Mozilla Firefox 4 to*/ 5 Color:#999;6}7 ::-moz-placeholder{/*Mozilla Firefox 19+*/ 8 Color:#999;9}Ten :-ms-input-placeholder{/*Internet Explorer + +*/  One Color:#999; A}

Textareas (text box can stretch) style style code, as follows:

12color: #636363345color: #636363 6

The font colors for input and textarea are all red. All styles are based on different selectors, and do not package the whole process because one of the problems, the others will fail.

  1  *::-webkit-input-placeholder  { Span style= "color: #008080;" > 2  color :  red ; }  4  *:- Moz-placeholder  { 5  color :  red ; }  7  *:- Ms-input-placeholder  { 8  /*   ie10+   9  color :  red ; 10 } 

In Firefox and IE, the normal input text color overrides the placeholder color method:

1 ::-webkit-input-placeholder{2 Color:Red;Text-overflow:ellipsis;3}4 :-moz-placeholder{5 Color:#acacac!important;Text-overflow:ellipsis;6}7 ::-moz-placeholder{8 Color:#acacac!important;Text-overflow:ellipsis;9}/* for the future*/ Ten :-ms-input-placeholder{ One Color:#acacac!important;Text-overflow:ellipsis; A}

There is also a good way:

1 Input::-webkit-input-placeholder, Textarea::-webkit-input-placeholder{2 Color:#666;3}4 Input:-moz-placeholder, Textarea:-moz-placeholder{5 Color:#666;6}7 Input::-moz-placeholder, Textarea::-moz-placeholder{8 Color:#666;9}Ten Input:-ms-input-placeholder, Textarea:-ms-input-placeholder{ One Color:#666; A}

How to modify HTML5 input placeholder color

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.