Form textarea style (css)

Posted on 2011-10-12
Last Modified: 2012-06-27
Hi E's, I try to give a style to the text inside <textarea> in this way:
<textarea name="descricao" cols="80" rows="8" onclick="clearText(this)"/><a class="sub_texto_form_novo">descrição</a></textarea>

Open in new window

When I see the result is a disaster, appear inside textarea: "<a class="sub_texto_form_novo">descrição</a>" when should appear just "descrição".

My question is, is possible give style to the text inside <textarea>? and how?

The best regards, JC
Question by:Pedro Chagas
    LVL 9

    Expert Comment


     <textarea   cols="80" rows="8" onclick="clearText(this)" style="border: 1px solid black;"><a class="sub_texto_form_novo">descrição</a>
    LVL 9

    Expert Comment

    Where style is any style you want to apply to the textarea tag.
    LVL 42

    Accepted Solution

    No, you can't style portions of text inside a <textarea>. In other words, <textarea>s only support plain text.

    To be able to style sections of text inside a text field, you need to use rich-text editor script.

    By the way, the slash at the end of the start tag means that the element doesn't have an end tag. Be sure it's not in any of start tags of <textarea> elements in your pages.
    LVL 3

    Author Comment

    by:Pedro Chagas
    No, just the text inside text area.
    LVL 42

    Expert Comment

    by:David S.
    If you want to apply a style to all of the text in the <textarea>, then you could simply give the class to the <textarea> it self.

    <textarea name="descricao" cols="80" rows="8" onclick="clearText(this)" [b]class="sub_texto_form_novo">[/b]descrição</textarea>

    Open in new window

    Of course, that single change won't be enough if there's a style for "a.sub_texto_form_novo", but not ".sub_texto_form_novo".

    By the way, you might want to reconsider clearing the text in the textarea any time someone clicks on it, because someone may well click on it after they have already entered some text.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
    So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
    In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now