InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS selectors

    Simple Selectors

    • type selectors
    • universal selector (*)
    • attribute presence and value selectors
    • attribute substring selectors
    • class selectors
    • two classes (.c1.c2)
    • id selectors

    Pseudo-classes

    • :link
    • :visited
    • :hover
    • :active
    • :focus
    • :target
    • :lang
    • :enabled and :disabled
    • :checked
    • :root
    • :nth-child
    • :nth-of-type
    • :nth-child vs :nth-of-type
    • :nth-last-child
    • :nth-last-of-type
    • :first-child
    • :first-of-type
    • :last-child
    • :last-of-type
    • :only-child
    • :only-of-type
    • :empty
    • :not

    Pseudo-elements

    • ::first-line
    • ::first-letter
    • ::before and ::after
    • ::placeholder

    Combinators

    • child vs descendant selector
    • adjacent sibling selector (E1 + E2)
    • general sibling selector (E1 ~ E2)

    Specificity

    • Selector specificity
     
    • Home
    • > Tutorials
    • > CSS
    • > CSS selectors

    CSS placeholder style

    on Feb 29, 2016

    CSS input and textarea ::placeholder pseudo element can be used to add a placeholder text in input element. The text is set using input element attribute placeholder. The placeholder text can be styled using css placeholder pseudo element (or pseudo class in some browser). Note that pseudo class uses single colon (:) whereas pseudo element uses double colon (::) syntax. The support for css placeholder pseudo element is still prefix based in browsers (as on Feb 19, 2016).

    css-selector-placeholder

    input placeholder css example

    <style type="text/css">
    .foo::-webkit-input-placeholder { /* chrome/opera/safari/edge */
      color:   lightblue;
    }
    .foo::-moz-placeholder { /* Firefox */
      color:  lightblue;
    }
    .foo:-ms-input-placeholder { /* IE 10+ */
      color:  lightblue;
    }
    </style>
    <input class="foo" type="text" placeholder="Colored placeholder text">
    <input type="text" placeholder="Placeholder text">
    refresh done
    try it online

    textarea placeholder css example

    <style type="text/css">
    ::-webkit-input-placeholder { /* chrome/opera/safari/edge */
      color:   lightblue;
    }
    ::-moz-placeholder { /* Firefox */
      color:  lightblue;
    }
    :-ms-input-placeholder { /* IE 10+ */
      color:  lightblue;
    }
    </style>
    <textarea placeholder="Textarea placeholder text" cols=40 rows=5>
    </textarea>
    refresh done
    try it online

    Specification and Browser compatibility

    SpecificationStatusCategories
    ::placeholder CSS pseudo-elementW3C Working DraftCSS
    Desktop
    ChromeFirefoxIEEdgeSafariOpera
    Partial 4+ (with prefix)Yes 19+ (with prefix)Partial 10+ (with prefix)Partial 12+ (with prefix)Partial 5+ (with prefix)Partial 15+ (with prefix)
    Mobile
    Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
    Partial 47+ (with prefix)Yes 44+ (with prefix)Partial 4.2-4.3+ (with prefix)Partial 10+ (with prefix)Partial 33+ (with prefix)
    source: caniuse.com

    Suggested posts:

    1. How to install polymer
    2. CSS pseudo class :lang
    3. CSS :nth-of-type
    4. CSS :only-child – define style if element if only child
    5. jQuery ui slider and input text box – one way binding
    6. CSS animation shorthand property
    7. CSS flexbox – display flex and inline-flex
    8. CSS pseudo class :focus
    Share this article: share on facebook share on linkedin tweet this submit to reddit
    Posted in Tutorials | Tagged CSS, CSS Pseudo Elements, CSS selectors, HTML5, Tutorials
    • Browse content
    • Article Topics
    • Article archives
    • Contact Us
    Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

    Copyright © 2025 InfoHeap.

    Powered by WordPress