Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Form textarea style (css)

Posted on 2011-10-12
Medium Priority
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
  • 2
  • 2

Expert Comment

ID: 36958969

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

Expert Comment

ID: 36958971
Where style is any style you want to apply to the textarea tag.
LVL 43

Accepted Solution

David S. earned 2000 total points
ID: 36959004
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.

Author Comment

by:Pedro Chagas
ID: 36959010
No, just the text inside text area.
LVL 43

Expert Comment

by:David S.
ID: 36959070
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

581 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