Using the VS Code Live Server extension and Chrome. For some reason I can change all other properties of the textbox, but not the text color– why?
textbox.html:
<!DOCTYPE html>
<html>
<head>
<title>Search Google</title>
<link rel="stylesheet" href="textbox.css">
</head>
<body>
<input id="search-box" type="text" placeholder="Search Google or type a URL">
</body>
</html>
textbox.css:
#search-box {
font-family: Arial;
font-size: 16px;
background-color: red;
color: blue;
}
2
Answers
The
color
property only styles the text a user types into the form field. To color the placeholder text, you need to use the::placeholder
pseudo-element:You can only change the input text colors, but you can’t change the placeholder text colors. If you want to set the placeholder text colors, you can do the following: