Is there a way to style textarea content as the user types with javascript and css?

css, forms, html, javascript, jquery

Solution

You can use a `div` with `contentEditable` attribute instead of `textarea` and to do the highlighting there.

https://developer.mozilla.org/en-US/docs/HTML/Content_Editable

You will still need to copy the content of this `div` to a hidden field of a form if you need to post it.

Problem

I'm curious if there's a way to style content in a textarea as a user types. For example: ``` <textarea>abcdefghijklmnopqrstuvwxyz</textarea> ``` Could I highlight all the vowels in the above textarea string on screen using javascript? But still only send the string when the form is submitted?

Original source

Related problems