::placeholder 의사 요소를 사용하여 텍스트 상자의 자리 표시자 텍스트 색상을 변경할 수 있습니다.
CSS ::placeholder 의사 요소의 구문은 다음과 같습니다 -
::placeholder {
attribute: /*value*/
} 예시
다음 예는 CSS ::자리 표시자 의사 요소를 보여줍니다.
<!DOCTYPE html>
<html>
<head>
<style>
input:last-child::placeholder {
color: cornflowerblue;
}
</style>
</head>
<body>
<input type="text" placeholder="Default color" />
<input type="text" placeholder="Check my new color :D" />
</body>
</html> 출력
이것은 다음 결과를 생성합니다 -

예시
<!DOCTYPE html>
<html>
<head>
<style>
input::placeholder {
color: fuchsia;
}
input {
margin: 2%;
width: 100%;
}
div {
display: flex;
flex-direction: column;
margin: 3%;
padding: 3%;
text-align: center;
align-items: center;
box-shadow: inset 0 0 30px brown;
}
button {
width: 40%;
}
</style>
</head>
<body>
<div>
<input type="text" placeholder="Normal placeholder" />
<input type="email" placeholder="somenone@somewhere.com" />
<button>dummy btn</button>
</div>
</body>
</html> 출력
이것은 다음 결과를 생성합니다 -
