Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:56:21+00:00 2026-06-14T22:56:21+00:00

I’d like to be able to syntax-highlight a small amount of editable text in

  • 0

I’d like to be able to syntax-highlight a small amount of editable text in a webpage, with only a few variations in foreground color. (Let’s say three, for the sake of argument.)

My annoying experiences with Online Rich-Text Editors led me to think that reigning in their loose ends is not worth it. So I got the wacky idea to layer several fixed-width-font <textarea> elements on top of each other, and keep them in sync. Each would have a different foreground color, and through background transparency you’d just leave gaps wherever a certain layer wasn’t supposed to print. The browser would do the compositing and all would be well, maybe.

Some exploratory tests in Opera, Chrome, Firefox, and Safari suggested to my surprise that this actually works (nutty as it may sound). But one of the biggest reasons why I want to use very plain text is so that copy and paste are foolproof. Yet when the text has been broken out into layers like this, there’s no union the user can select in and get all the text in its raw form.

My first impulse was to stack on a top-level layer of text which was sync’d to contain content from all layers, but whose color was transparent. Once again, it “worked”…but unfortunately, pretty much all browsers cue the insertion point color from the textarea color that is active. That means the caret becomes invisible, and in some browsers so does the text you’re selecting. (!)

So I solicit insights from those who know more than I about this. Can I hook such a stack in a cross-browser way so that the selection is readable while you’re making it and when the user does “copy” gets the merged text? Has anyone ever tried something like this? Or is there a proof of “that’s a terrible idea and there’s no way you’ll get it to work”? If I could get cross-browser notifications of when the selection changed, I could inject the merged characters into the layer being selected at the points inside the selection. :-/

(Oh what a tangled web we weave…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:56:25+00:00Added an answer on June 14, 2026 at 10:56 pm

    It’ll be far quicker for you to use existing solutions. Please look at ACE editor:

    http://ace.ajax.org

    ACE is an embeddable code editor written in JavaScript. It matches the features and performance of native editors such as Sublime, Vim and TextMate. It can be easily embedded in any web page and JavaScript application. ACE is maintained as the primary editor for Cloud9 IDE and is the successor of the Mozilla Skywriter (Bespin) project.

    Specifically this rich-text editor has facilities to show syntax highlighting and to show errors/line numbers, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.