Home Forums General XMetaL Discussion CSS to colour a parent element based on content of attribute on a child element Reply To: CSS to colour a parent element based on content of attribute on a child element

Derek Read

Reply to: CSS to colour a parent element based on content of attribute on a child element

I agree that there is not going to be a way to do this given current functionality with our CSS, which basically follows the W3C Recommendations.

In theory a feature could be added that is non-standard CSS that might help, but for the most part we would prefer to follow the W3C CSS Recommendations so that people familiar with CSS can easily adapt that knowledge when defining CSS to be used with our products. CSS selectors basically work by finding a particular element in a top down manner, and then styling the innermost element in that top-down structure.

What you seem to be asking for is another type of selector that works from the bottom-up and that styles the outermost element. This is an interesting idea but I don't see the W3C moving in this direction at the moment.

As such, a scripting solution for this is likely the only approach, requiring this very basic logic:

1. Find the elements you wish to style (by walking the DOM, using Range objects, or perhaps Document.getNodesByXPath).
2. Style each of the elements you find using the Selection.ContainerStyle API.

Reply

Products
Downloads
Support