0

How can I add a star with other color in placeholder for <input type="text" /> like this? placeholder with formatting

Nathan Taylor
  • 24,423
  • 19
  • 99
  • 156
truslivii.lev
  • 701
  • 1
  • 8
  • 21

2 Answers2

5

http://jsfiddle.net/coma/fuexebw7/

::-webkit-input-placeholder:after {
    content: "*";
    color: red;
}
coma
  • 16,429
  • 4
  • 51
  • 76
1

You cannot add html formatting to a placeholder, but you could achieve what you are looking for with relatively position element (label) which has visibility settings bound to various interactions with the input. Essentially, when the text field is being modified or has a value, you hide the label, when it is empty, you show it.

Alternatively, you can use the example provided by coma to modify the placeholder with CSS, but that will not be cross-browser compatible.

Nathan Taylor
  • 24,423
  • 19
  • 99
  • 156
  • hummm, yes you can: http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css , obviously not that browser friendly wide. – coma Oct 20 '14 at 22:34