CSS

How To Change the Input Placeholder Color Using CSS?

In this article, we will discuss How To Change the Input Placeholder Color Using CSS? By default, the input placeholder text is showing in light gray color, and no any standard CSS property to style it. we can change the placeholder color using the non-standard ::placeholder selector. Note that by default Firefox uses a lower opacity to the placeholder, so we need to change opacity: 1 to fix this. as shown in the following example:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Change Placeholder text color with CSS</title>
<style>
    ::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */    color: red;
    opacity: 1; /* Firefox */  }

  :-ms-input-placeholder { /* Internet Explorer 10-11 */    color: red;
  }

  ::-ms-input-placeholder { /* Microsoft Edge */    color: red;
  }
</style>
</head>
<body>
    <form>
        <input type="text" placeholder="You Name">
    </form>
</body>
</html>

Result:

Rahul Chopda

Rahul Chopda is a web designer and front-end web developer with experience in HTML, CSS, jQuery also Author at TheCodeHubs.

Share
Published by
Rahul Chopda
Tags: CSSHTML

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago