5 replies [Last post]
r3gan
Offline
newbie
Canada
Last seen: 16 years 16 weeks ago
Canada
Timezone: GMT-7
Joined: 2004-08-05
Posts: 3
Points: 0

I am wanting to create a default style that will be used for all <input> tags on my page. Is there as way that I can set a default style for <input type="text"> and then a different one for <input type="password"> or <input type="button"> ? I tried this:

input {
background-color: red;
}

but that changes the background color for all <input> elements. I then tried:

input:text (and input.text) {
background-color: red;
}

but that didn't do anything at all. Can anyone help me out? Thanks in advance.

loudsox04
Offline
Regular
Boston, MA
Last seen: 16 years 21 weeks ago
Boston, MA
Timezone: GMT-4
Joined: 2004-07-06
Posts: 33
Points: 0

Question about default styles for &lt;input&gt; tags.

Try using classes instead of "type," ie specify classes in the css like input.text, imput.password, etc., then refrence them the html like <input class = "text">, etc. Hope that helps. Smile - Jen

r3gan
Offline
newbie
Canada
Last seen: 16 years 16 weeks ago
Canada
Timezone: GMT-7
Joined: 2004-08-05
Posts: 3
Points: 0

Question about default styles for &lt;input&gt; tags.

Hmmm yes that seems to work, I guess I will just have to specify a class for all of the <input> tags. I was hoping to not have to do that.

thepineapplehead
thepineapplehead's picture
Offline
Guru
Last seen: 36 weeks 2 days ago
Joined: 2004-06-30
Posts: 9668
Points: 801

Question about default styles for &lt;input&gt; tags.

YOu can just use

input {
background-color: red;
}

then make a class called

.password {
background-color: blue;
}

and in the html use <input class="password" etc etc>

Verschwindende wrote:
  • CSS doesn't make pies

r3gan
Offline
newbie
Canada
Last seen: 16 years 16 weeks ago
Canada
Timezone: GMT-7
Joined: 2004-08-05
Posts: 3
Points: 0

Question about default styles for &lt;input&gt; tags.

Yeah, I know how to get around it by using specific classes, but I have the rest of my page set with default styles (like one for all default <td> tags, etc.) and I wanted to do the same for <input> tags... I guess it can't be done.

thepineapplehead
thepineapplehead's picture
Offline
Guru
Last seen: 36 weeks 2 days ago
Joined: 2004-06-30
Posts: 9668
Points: 801

Question about default styles for &lt;input&gt; tags.

Yes it can - use

input {
blah
}

for all input boxes, but use a class for ones you want to style differently.

Verschwindende wrote:
  • CSS doesn't make pies