The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Transparent text, visible caret? Reply To: Transparent text, visible caret?

Nathan K

I wish to apply different styles to different parts of a textarea. I’ve already accomplished this using a contentEditable div tag, but this has many shortcomings since it allows the user to paste not only plain text into the box, but also HTML elements (which ruin the formatting). There are ways around this, such as capturing ctrl+v with javascript, but this does not work when using the menubar to paste, or when using android to paste, for example.

As a more robust solution, I got the idea to have a div in the backround, and a transparent textarea on top of it which the user inputs into. Javascript then processes the input before adding it to the background div to be displayed. This solution seems ideal because I want plain text input, but HTML output.