How to change the color of the placeholder attribute with CSS?



To change the color of the placeholder attribute with CSS, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      padding: 20px;
   }
   input {
      font-size: 40px;
      font-weight: bold;
   }
   ::placeholder {
      color: rgb(70, 53, 167);
   }
   :-ms-input-placeholder {
      color: rgb(66, 51, 155);
   }
   ::-ms-input-placeholder {
      color: rgb(122, 69, 182);
   }
</style>
</head>
<body>
<h1>Placeholder color change example</h1>
<input type="text" placeholder="Some placeholder text" />
</body>
</html>

Output

The above code will produce the following output −


Advertisements