Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textarea multiple text colors

Status
Not open for further replies.

Rekcor

Programmer
Feb 15, 2005
48
NL
Is it possible, using javascript:

1) to give the text inside a textarea a different color
2) to give different words inside a textarea a different color? E.g. "The red car had some blue scratches on it"

As you might guess, the second question interests me most ;)
 
Not inside a textarea no. Inside a div tag with the CONTENTEDITABLE flag set to true - yes.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
 
Well.. point 2 is not possible with a standard textarea element cross-browser. Point 1 would be possible with css:

Code:
<style type="text/css">
   #myTextArea {
      color: red;
   }
</style>

...

<textarea id="myTextArea">Some text</textarea>

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top