Jan Chalupa
Jan Chalupa

Reputation: 897

HTML + JS: Best way to style up textarea's content

What is the best way to style up content in the HTML textarea element. My goal is to have parts of text in my textarea red (for example), so I would do <span style="color: red">My text part</span> but this way the textarea shows everything including my HTML code <span> ... </span> as its value.

Next thing I tried is to overlay div with my textarea in which would be my desired code width <span> ... </span> code shown correctly with red styled text and without HTML code. User will edit textarea's value which would be processed and shown in my div. But this method seems to me too dirty. What is your advises?

Upvotes: 0

Views: 123

Answers (1)

Styling text inside a textarea is not possible, you can check this. You could use a plugin like TinyMCE, which will show a text editor in the place of your textarea, and there you can put the style that you want to the text.

Upvotes: 3

Related Questions