Swami Kevala wrote: > > Does anybody know if it is possible to conditionally specify generated > content using the before: pseudo-function based on whether or not a > certain attribute exists? I have an element which has two attributes, > one of which is mandatory, and one is optional. I want to generate a > label for the mandatory attribute followed by a control for it, and then > - if the optional attribute exists - display a label for that also, > followed by it's control.
You can do this using the standard CSS attribute selectors. See http://www.w3.org/TR/REC-CSS2/selector.html#attribute-selectors myelement:before { display: ZZZ; content: "my label 1 " mycontrol(); } myelement[myoptionalattr]:before { display: ZZZ; content: "my label 1 " mycontrol() " my label 2 " myothercontrol(); }

