Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to select multiple input field types with CSS?

I have a text and a password input field that I'm trying to select in this fashion:

input[type=text][type=password] 

however this does not work. I would refrain from using jQuery, so any help would be appreciated (without using custom classes).

like image 677
Joanna Avatar asked Sep 19 '11 16:09

Joanna


People also ask

How do I select all input types in CSS?

Element Selectors The selector "input[type=text]" means select all inputs with the type attribute equal to text.

Can I select multiple elements at once with CSS?

When you group CSS selectors, you apply the same styles to several different elements without repeating the styles in your stylesheet. Instead of having two, three, or more CSS rules that do the same thing (set the color of something to red, for example), you use a single CSS rule that accomplishes the same thing.

How do you input multiple values in HTML?

When present, it specifies that the user is allowed to enter more than one value in the <input> element. Note: The multiple attribute works with the following input types: email, and file. Tip: For <input type="file"> : To select multiple files, hold down the CTRL or SHIFT key while selecting.


1 Answers

You need to specify the attributes separately, repeating the types if necessary and using comma(s):

input[type=text], input[type=password] 

Your given selector is trying to match an input with a type that is both text and password, but a single element can't have different values for the same attribute so it fails.

like image 171
BoltClock Avatar answered Sep 23 '22 07:09

BoltClock