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?
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!
[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.
The universal selector, written "*", matches the name of any element type.
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; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With