Solved

How do I create a global CSS statement for all input fields on all my .aspx pages

Posted on 2010-09-17
5
332 Views
Last Modified: 2012-05-10
Is there a way to define a global style that will cover all the input elements throughout my site? I don't want to have to assign the style to each element (ie cssClass=).

Something like: BODY {font-family: serif; background-color: silver;}  only to cover asp:textbox, asp:dropdownlist, etc.

tried INPUT.TEXT{ }.... this doesn't work

Thanks
0
Comment
Question by:Bob Hoffman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 9

Expert Comment

by:TonyReba
ID: 33705905
if you dont want to use a class,

input[type=button], input[type=submit]
{
width:auto;
padding:3px 6px;
color:#ffffff;
text-align:center;
background:#e2212a;
font-size:11px;
font-weight:bold;
border:0px;
margin:2px;
cursor:pointer;
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;

}

Open in new window

0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33705909
0
 
LVL 9

Accepted Solution

by:
TonyReba earned 500 total points
ID: 33705920
this goes in your head secition
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>-z-</title>
<style type="text/css">
input, textarea {
border: 2px solid #d69;
background: #999;
float: left;
clear: left;
width: 250px;
margin: 10px 0;
padding: 6px;
font: 1.2em monospace;
color: #fc3;
letter-spacing: .07em;
}
</style>
</head>

Open in new window

0
 
LVL 1

Expert Comment

by:Hafeez Ansari
ID: 33708630
You can do it in 2 different ways, first method is to write css codes direct for input elements e.g.

input[type=text]
{
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding:4px;
font:12px;
}
in the above mentioned codes you are writing codes to apply directly on input type. and wherever you'll use in html <input type="text"............. /> these codes will automatically apply to all inputs.
But you can do the same thing in another way, first write a style class and then apply to the concerning elements e.g.
.textEntry
{
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding:4px;
font:12px;
}
now you have a class named 'textEntry' in your css and you can apply this class to the elements for example:
<input class="textEntry" type="text size="25" value="" />

hope this will be helpful to you.
0
 
LVL 8

Author Closing Comment

by:Bob Hoffman
ID: 33711550
This did the trick... added "select" to handle the dropdown lists.

input, textarea, select {}

Thanks everyone.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

752 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