javascripthtmlrichtextboxwidgethighlighting

Textarea that can do syntax highlighting on the fly?


I am storing a number of HTML blocks inside a CMS for reasons of easier maintenance. They are represented by <textarea>s.

Does anybody know a JavaScript Widget of some sort that can do syntax highlighting for HTML within a textarea or similar, while still staying a plain text editor (no WYSIWYG or advanced functions)?


Solution

  • It's not possible to achieve the required level of control over presentation in a regular <textarea>.

    If you're OK with that, try CodeMirror or Ace or Monaco (used in VS Code).

    See Comparison of JavaScript-based source code editors on Wikipedia.