Is it possible to have several different textcolors in one textarea?












16














I'd like several words / phases in a textarea to appear in different colors... How would I go about doing this? Below is an example, I'd like the word green to appear green etc etc...



<textarea style="width: 100%; height: 100%; resize: none;">
Is it possible to have multiple colors in a textarea?
How would i set certain phases or words to be different colors?
"Green"
"Red"
"Blue"
</textarea>









share|improve this question





























    16














    I'd like several words / phases in a textarea to appear in different colors... How would I go about doing this? Below is an example, I'd like the word green to appear green etc etc...



    <textarea style="width: 100%; height: 100%; resize: none;">
    Is it possible to have multiple colors in a textarea?
    How would i set certain phases or words to be different colors?
    "Green"
    "Red"
    "Blue"
    </textarea>









    share|improve this question



























      16












      16








      16


      1





      I'd like several words / phases in a textarea to appear in different colors... How would I go about doing this? Below is an example, I'd like the word green to appear green etc etc...



      <textarea style="width: 100%; height: 100%; resize: none;">
      Is it possible to have multiple colors in a textarea?
      How would i set certain phases or words to be different colors?
      "Green"
      "Red"
      "Blue"
      </textarea>









      share|improve this question















      I'd like several words / phases in a textarea to appear in different colors... How would I go about doing this? Below is an example, I'd like the word green to appear green etc etc...



      <textarea style="width: 100%; height: 100%; resize: none;">
      Is it possible to have multiple colors in a textarea?
      How would i set certain phases or words to be different colors?
      "Green"
      "Red"
      "Blue"
      </textarea>






      html css






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 1 '14 at 13:14









      Benjamin

      15.9k28120230




      15.9k28120230










      asked Aug 8 '10 at 16:47









      DavidDavid

      4,756123545




      4,756123545
























          6 Answers
          6






          active

          oldest

          votes


















          12














          You can't do this inside a <textarea>, not one that's editable. It sounds like you're after a WYSIWYG editor, most of which use a <iframe> to do this.



          There are several JavaScript options for this, to name a few:




          • TinyMCE

          • CKEditor






          share|improve this answer





















          • Sure you can! in-fact what you call a "rich text-box" editor is an editable div, highlighted using CSS or inline-styling (all of WordPress plugins, MCE and editors work this way. See answer below.
            – user257319
            Nov 7 '15 at 21:40



















          6














          I don't think its possible to do that with a textarea and html alone. What you need is a Rich Text box
          You can either roll your own or use the popular ones available



          Other option you can have when you target html5 enabled browsers is the contentEditable attribute. You can use it to make a textbox-like control






          share|improve this answer





























            6














            You cannot do this with a textarea or input tag. However, as @naikus mentioned, you can use the contenteditable attribute. It is as follows:



            <div id="mytxt" contenteditable="true">
            Hello, my name is <span style="color: blue;">Bob</span>
            and I have a friend name <span style="color: green;">Joe</span>.
            </div>





            <div id="mytxt" contenteditable="true">
            Hello, my name is <span style="color: blue;">Bob</span> and I have a friend name <span style="color: green;">Joe</span>.
            </div>








            share|improve this answer





























              2














              This is not possible in a normal textarea.




              • For syntax highlighting-like approaches, see the answers to this question.


              • For a more complicated, full-fledged WYSIWYG solution that can do colours as well as other formatting, images, etc., see a WYSIWYG editor like CKEditor.







              share|improve this answer































                1














                You can't do this with default html controls. You can use Rich Text Box editors to get what you want, for example check this question:



                What is the best rich textarea editor for jQuery?






                share|improve this answer































                  1














                  That's not possible with current w3c specs. If you're looking for a workaround, check codemirror or editArea for their workarounds for syntax highlighting.






                  share|improve this answer





















                  • hmm someone downvoted, wonder why. I don't care about the 2 fake internet points gone from my profile, but would like to know the reason. anyone?
                    – Sinan
                    Nov 9 '15 at 0:01











                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3435167%2fis-it-possible-to-have-several-different-textcolors-in-one-textarea%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  6 Answers
                  6






                  active

                  oldest

                  votes








                  6 Answers
                  6






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  12














                  You can't do this inside a <textarea>, not one that's editable. It sounds like you're after a WYSIWYG editor, most of which use a <iframe> to do this.



                  There are several JavaScript options for this, to name a few:




                  • TinyMCE

                  • CKEditor






                  share|improve this answer





















                  • Sure you can! in-fact what you call a "rich text-box" editor is an editable div, highlighted using CSS or inline-styling (all of WordPress plugins, MCE and editors work this way. See answer below.
                    – user257319
                    Nov 7 '15 at 21:40
















                  12














                  You can't do this inside a <textarea>, not one that's editable. It sounds like you're after a WYSIWYG editor, most of which use a <iframe> to do this.



                  There are several JavaScript options for this, to name a few:




                  • TinyMCE

                  • CKEditor






                  share|improve this answer





















                  • Sure you can! in-fact what you call a "rich text-box" editor is an editable div, highlighted using CSS or inline-styling (all of WordPress plugins, MCE and editors work this way. See answer below.
                    – user257319
                    Nov 7 '15 at 21:40














                  12












                  12








                  12






                  You can't do this inside a <textarea>, not one that's editable. It sounds like you're after a WYSIWYG editor, most of which use a <iframe> to do this.



                  There are several JavaScript options for this, to name a few:




                  • TinyMCE

                  • CKEditor






                  share|improve this answer












                  You can't do this inside a <textarea>, not one that's editable. It sounds like you're after a WYSIWYG editor, most of which use a <iframe> to do this.



                  There are several JavaScript options for this, to name a few:




                  • TinyMCE

                  • CKEditor







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 8 '10 at 16:51









                  Nick CraverNick Craver

                  530k11511921098




                  530k11511921098












                  • Sure you can! in-fact what you call a "rich text-box" editor is an editable div, highlighted using CSS or inline-styling (all of WordPress plugins, MCE and editors work this way. See answer below.
                    – user257319
                    Nov 7 '15 at 21:40


















                  • Sure you can! in-fact what you call a "rich text-box" editor is an editable div, highlighted using CSS or inline-styling (all of WordPress plugins, MCE and editors work this way. See answer below.
                    – user257319
                    Nov 7 '15 at 21:40
















                  Sure you can! in-fact what you call a "rich text-box" editor is an editable div, highlighted using CSS or inline-styling (all of WordPress plugins, MCE and editors work this way. See answer below.
                  – user257319
                  Nov 7 '15 at 21:40




                  Sure you can! in-fact what you call a "rich text-box" editor is an editable div, highlighted using CSS or inline-styling (all of WordPress plugins, MCE and editors work this way. See answer below.
                  – user257319
                  Nov 7 '15 at 21:40













                  6














                  I don't think its possible to do that with a textarea and html alone. What you need is a Rich Text box
                  You can either roll your own or use the popular ones available



                  Other option you can have when you target html5 enabled browsers is the contentEditable attribute. You can use it to make a textbox-like control






                  share|improve this answer


























                    6














                    I don't think its possible to do that with a textarea and html alone. What you need is a Rich Text box
                    You can either roll your own or use the popular ones available



                    Other option you can have when you target html5 enabled browsers is the contentEditable attribute. You can use it to make a textbox-like control






                    share|improve this answer
























                      6












                      6








                      6






                      I don't think its possible to do that with a textarea and html alone. What you need is a Rich Text box
                      You can either roll your own or use the popular ones available



                      Other option you can have when you target html5 enabled browsers is the contentEditable attribute. You can use it to make a textbox-like control






                      share|improve this answer












                      I don't think its possible to do that with a textarea and html alone. What you need is a Rich Text box
                      You can either roll your own or use the popular ones available



                      Other option you can have when you target html5 enabled browsers is the contentEditable attribute. You can use it to make a textbox-like control







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 8 '10 at 16:53









                      naikusnaikus

                      21.3k43443




                      21.3k43443























                          6














                          You cannot do this with a textarea or input tag. However, as @naikus mentioned, you can use the contenteditable attribute. It is as follows:



                          <div id="mytxt" contenteditable="true">
                          Hello, my name is <span style="color: blue;">Bob</span>
                          and I have a friend name <span style="color: green;">Joe</span>.
                          </div>





                          <div id="mytxt" contenteditable="true">
                          Hello, my name is <span style="color: blue;">Bob</span> and I have a friend name <span style="color: green;">Joe</span>.
                          </div>








                          share|improve this answer


























                            6














                            You cannot do this with a textarea or input tag. However, as @naikus mentioned, you can use the contenteditable attribute. It is as follows:



                            <div id="mytxt" contenteditable="true">
                            Hello, my name is <span style="color: blue;">Bob</span>
                            and I have a friend name <span style="color: green;">Joe</span>.
                            </div>





                            <div id="mytxt" contenteditable="true">
                            Hello, my name is <span style="color: blue;">Bob</span> and I have a friend name <span style="color: green;">Joe</span>.
                            </div>








                            share|improve this answer
























                              6












                              6








                              6






                              You cannot do this with a textarea or input tag. However, as @naikus mentioned, you can use the contenteditable attribute. It is as follows:



                              <div id="mytxt" contenteditable="true">
                              Hello, my name is <span style="color: blue;">Bob</span>
                              and I have a friend name <span style="color: green;">Joe</span>.
                              </div>





                              <div id="mytxt" contenteditable="true">
                              Hello, my name is <span style="color: blue;">Bob</span> and I have a friend name <span style="color: green;">Joe</span>.
                              </div>








                              share|improve this answer












                              You cannot do this with a textarea or input tag. However, as @naikus mentioned, you can use the contenteditable attribute. It is as follows:



                              <div id="mytxt" contenteditable="true">
                              Hello, my name is <span style="color: blue;">Bob</span>
                              and I have a friend name <span style="color: green;">Joe</span>.
                              </div>





                              <div id="mytxt" contenteditable="true">
                              Hello, my name is <span style="color: blue;">Bob</span> and I have a friend name <span style="color: green;">Joe</span>.
                              </div>








                              <div id="mytxt" contenteditable="true">
                              Hello, my name is <span style="color: blue;">Bob</span> and I have a friend name <span style="color: green;">Joe</span>.
                              </div>





                              <div id="mytxt" contenteditable="true">
                              Hello, my name is <span style="color: blue;">Bob</span> and I have a friend name <span style="color: green;">Joe</span>.
                              </div>






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 30 '16 at 21:15









                              IamGuestIamGuest

                              417314




                              417314























                                  2














                                  This is not possible in a normal textarea.




                                  • For syntax highlighting-like approaches, see the answers to this question.


                                  • For a more complicated, full-fledged WYSIWYG solution that can do colours as well as other formatting, images, etc., see a WYSIWYG editor like CKEditor.







                                  share|improve this answer




























                                    2














                                    This is not possible in a normal textarea.




                                    • For syntax highlighting-like approaches, see the answers to this question.


                                    • For a more complicated, full-fledged WYSIWYG solution that can do colours as well as other formatting, images, etc., see a WYSIWYG editor like CKEditor.







                                    share|improve this answer


























                                      2












                                      2








                                      2






                                      This is not possible in a normal textarea.




                                      • For syntax highlighting-like approaches, see the answers to this question.


                                      • For a more complicated, full-fledged WYSIWYG solution that can do colours as well as other formatting, images, etc., see a WYSIWYG editor like CKEditor.







                                      share|improve this answer














                                      This is not possible in a normal textarea.




                                      • For syntax highlighting-like approaches, see the answers to this question.


                                      • For a more complicated, full-fledged WYSIWYG solution that can do colours as well as other formatting, images, etc., see a WYSIWYG editor like CKEditor.








                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 23 '17 at 12:02









                                      Community

                                      11




                                      11










                                      answered Aug 8 '10 at 16:51









                                      Pekka 웃Pekka 웃

                                      355k1168401012




                                      355k1168401012























                                          1














                                          You can't do this with default html controls. You can use Rich Text Box editors to get what you want, for example check this question:



                                          What is the best rich textarea editor for jQuery?






                                          share|improve this answer




























                                            1














                                            You can't do this with default html controls. You can use Rich Text Box editors to get what you want, for example check this question:



                                            What is the best rich textarea editor for jQuery?






                                            share|improve this answer


























                                              1












                                              1








                                              1






                                              You can't do this with default html controls. You can use Rich Text Box editors to get what you want, for example check this question:



                                              What is the best rich textarea editor for jQuery?






                                              share|improve this answer














                                              You can't do this with default html controls. You can use Rich Text Box editors to get what you want, for example check this question:



                                              What is the best rich textarea editor for jQuery?







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited May 23 '17 at 12:25









                                              Community

                                              11




                                              11










                                              answered Aug 8 '10 at 16:52









                                              Pavel MorshenyukPavel Morshenyuk

                                              8,13842735




                                              8,13842735























                                                  1














                                                  That's not possible with current w3c specs. If you're looking for a workaround, check codemirror or editArea for their workarounds for syntax highlighting.






                                                  share|improve this answer





















                                                  • hmm someone downvoted, wonder why. I don't care about the 2 fake internet points gone from my profile, but would like to know the reason. anyone?
                                                    – Sinan
                                                    Nov 9 '15 at 0:01
















                                                  1














                                                  That's not possible with current w3c specs. If you're looking for a workaround, check codemirror or editArea for their workarounds for syntax highlighting.






                                                  share|improve this answer





















                                                  • hmm someone downvoted, wonder why. I don't care about the 2 fake internet points gone from my profile, but would like to know the reason. anyone?
                                                    – Sinan
                                                    Nov 9 '15 at 0:01














                                                  1












                                                  1








                                                  1






                                                  That's not possible with current w3c specs. If you're looking for a workaround, check codemirror or editArea for their workarounds for syntax highlighting.






                                                  share|improve this answer












                                                  That's not possible with current w3c specs. If you're looking for a workaround, check codemirror or editArea for their workarounds for syntax highlighting.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Aug 8 '10 at 16:54









                                                  SinanSinan

                                                  6,85563146




                                                  6,85563146












                                                  • hmm someone downvoted, wonder why. I don't care about the 2 fake internet points gone from my profile, but would like to know the reason. anyone?
                                                    – Sinan
                                                    Nov 9 '15 at 0:01


















                                                  • hmm someone downvoted, wonder why. I don't care about the 2 fake internet points gone from my profile, but would like to know the reason. anyone?
                                                    – Sinan
                                                    Nov 9 '15 at 0:01
















                                                  hmm someone downvoted, wonder why. I don't care about the 2 fake internet points gone from my profile, but would like to know the reason. anyone?
                                                  – Sinan
                                                  Nov 9 '15 at 0:01




                                                  hmm someone downvoted, wonder why. I don't care about the 2 fake internet points gone from my profile, but would like to know the reason. anyone?
                                                  – Sinan
                                                  Nov 9 '15 at 0:01


















                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.





                                                  Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                  Please pay close attention to the following guidance:


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3435167%2fis-it-possible-to-have-several-different-textcolors-in-one-textarea%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  404 Error Contact Form 7 ajax form submitting

                                                  How to know if a Active Directory user can login interactively

                                                  TypeError: fit_transform() missing 1 required positional argument: 'X'