Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attribute selector where value equals either A or B?

I was wondering if it is possible to specify elements in CSS where an attribute is equal to one of two values, something like this:

input[type=text][type=password]

However this selector does not seem to work (I assume because specifying the same attribute twice is not valid), does anyone know how to do this?

like image 494
Alex Hope O'Connor Avatar asked Jun 11 '11 02:06

Alex Hope O'Connor


People also ask

What is the use of * In attribute selector?

The [attribute*="value"] selector is used to select elements whose attribute value contains a specified value. The following example selects all elements with a class attribute value that contains "te": Note: The value does not have to be a whole word!

What are different attributes selectors explain?

[attribute] Selector: This type of attribute selector is used to select all the elements that have the specified attribute and applies the CSS property to that attribute. For example the selector [class] will select all the elements with the style attribute.

What is the selector used to identify all similar element?

The universal selector, written "*", matches the name of any element type.


1 Answers

Like this? http://jsfiddle.net/m242t/

HTML:

<form> Username: <input type="username" name="Username" value="Username" /><br /> Password: <input type="password" name="Password" value="Password" /><br /> <input type="submit" value="Submit" /> </form> 

CSS:

input[type="username"], input[type="password"] {     color: blue; } 
like image 129
ngen Avatar answered Oct 03 '22 18:10

ngen