I use an in house CMS to edit HTML and CSS inside of textarea elements. I use a custom user stylesheet to set a monospace font but that’s made me want some syntax highlighting.
I’m looking to be able to apply it in a similar method of applying user stylesheets, I.e. by URL and hopefully by ID or class. That way when I go to the page to edit the code it looks nice and I can tell if I’ve missed something like a quote easily.
Another idea is taking a look at editors like Codemirror or Brackets that are HTML/JS-based, and dissecting how they’re doing it. Typically, it’s a script to wrap elements/variables/declarations in spans with appropriate classes, then a stylesheet to colorize those spans accordingly.