Solved

CSS TextArea Formatting Using Input

Posted on 2011-09-28
3
584 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
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).

828 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