Every time I type a character in an input field, I parse the expression so that I get:
as Matt said, <input>
s don't support styling content. However, one possible solution could be to use a second <span>
that will contain the input's value, and show the styled content here. If that's not acceptable, then use contenteditable
as Matt suggested.
Text inputs do not support styled content. End of story.
A common solution is to use contenteditable instead.
You can sort of hack styling behind it if it's just for unimportant aesthetics.
<input>
transparent<span>
behind it<span>
(with appropriate styling) when the <input>
's contents changeHere's a quick demo.