Solved

CSS TextArea Formatting Using Input

Posted on 2011-09-28
3
575 Views
Last Modified: 2012-06-27
I'm using the following CSS to round the corners on my text boxes over the whole site.

input { border:1px solid; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; }

This works great on most browsers, but it doesn't effect the textarea boxes.  Is there a way to modify the formatting for the textarea boxes without having to edit each individual entry?

In other words, is there a way to modify the input commmand above to globally format the textarea as well as the text boxes?

Thanks!
0
Comment
Question by:digitility
3 Comments
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
ID: 36718580
You can just use textarea instead of input.

Input and textarea are 2 separate tags in HTML. So in CSS, you would have to treat them as 2 separate elements:

input, textarea { border:1px solid; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; }

Open in new window

0
 
LVL 8

Expert Comment

by:Jesse Matlock
ID: 36719389
+1 for LZ1's response.. textareas are inputs, but they are NOT styled using 'input'.. they are targeted using 'textarea' :) Alternatively, you can add a class or an ID to a specific textarea, if you only want to target specific textareas.. and then style that class or ID.. eg.:

input {border:1px solid;}
.rounded {border:1px solid; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;}

Open in new window


<input type="text" name="" class="rounded" value="" /> <!-- this input WILL have rounded corners -->

<input type="text" name="" class="" value="" /> <!-- this input WILL NOT have rounded corners -->

<textarea name="" rows="8" cols="40" class="rounded"></textarea><!-- this textarea WILL have rounded corners --> 

<textarea name="" rows="8" cols="40" class=""></textarea><!-- this textarea WILL NOT have rounded corners -->

Open in new window


When you create CSS styles like this, they become very easy to re-use and allow you to re-use CSS code across projects .. like a toolkit :)
0
 

Author Closing Comment

by:digitility
ID: 36932261
Awesome, works great. Thanks.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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!
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

786 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