This is an important message requiring you to make a choice if you're based in the EU.

CSS ::placeholder Pseudo Element

The ::placeholder pseudo-element selects <form> elements with placeholder text in an <input> field.

The placeholder text is set with the placeholder attribute, which specifies a hint that describes the expected value of an input field.

The ::placeholder selector works with the -webkit-, -moz-, -ms- prefixes for maximum browser compatibility.




::placeholder {
css declarations;


<!DOCTYPE html>
    <title>Title of the document</title>
      * {
      box-sizing: border-box;
      .container {
      margin: 20px auto;
      max-width: 250px;
      background-color: #8ebf42;
      padding: 20px;
      input {
      border: 1px solid #666666;
      background-color: #eeeeee;
      padding: 15px;
      margin-bottom: 20px;
      display: block;
      width: 100%;
      input::-webkit-input-placeholder {
      color: #666666;
      input::-moz-placeholder {
      color: #666666;
      input:-ms-input-placeholder {
      color: #666666;
      input::placeholder {
      color: #666666;
    <h2>::placeholder selector example</h2>
    <div class="container">
        <input type="text" placeholder="Lorem ipsum is simply...">
        <input type="date" placeholder="DD/MM/YYYY">

Browser support

57.0+ Partial 51.0+19.0-50.0
10.1+ 444.0+

Practice Your Knowledge

All of the below are prefixes the ::placeholder selector works with, except

Do you find this helpful?

Related articles