I want to target an HTML element when BOTH the id and class selectors match.
Ie, if the fieldset has id ‘id1’ AND class ‘collapsed’, some CSS rule applies (to ensure its height is reduced to zero).
CSS 2.1 docs suggest that multiple attribute selectors may fill this task:
http://www.w3.org/TR/CSS2/selector.html#matching-attrs
But the following syntax doesn’t seem to take effect (tested in Safari and FFox3):
div[id=id1][class=collapsed] { display: none ; }
Is there a way to do something like this?
div#id1.collapsed { /* rules */ }
You are doing it right, but the order of the selectors is wrong, you need to put the element first, then the class, and then the id
IMPORTANT EDIT:
Also works.