1

If I have an HTML5 text box as follows

<form>
    <input type="text" name="mytextbox" placeholder"MyTextBox"/>
</form>

is there a way using HTML or CSS to change the color of the placeholder/watermark from the default light gray?

xcdemon05
  • 678
  • 3
  • 7
  • 20

1 Answers1

3

See this answer.

Long story short, you need to use CSS Selectors to apply the rules to each browser, which handles the process differently.

input.mytextbox::-webkit-input-placeholder {
  /* WebKit browsers */
  color: red;
}

input.mytextbox:-moz-placeholder {
  /* Mozilla Firefox 4 to 18 */
  color: red;
  opacity: 1;
}

input.mytextbox::-moz-placeholder {
  /* Mozilla Firefox 19+ */
  color: red;
  opacity: 1;
}

input.mytextbox:-ms-input-placeholder {
  /* Internet Explorer 10+ */
  color: red;
}
<input class="mytextbox" type="text" name="mytextbox" placeholder="MyTextBox"/>
Community
  • 1
  • 1
Ben
  • 8,894
  • 7
  • 44
  • 80