[whatwg] New method for obtaining a CSS property

Ashley Sheridan ash at ashleysheridan.co.uk
Thu Jan 27 10:42:40 PST 2011

"Boris Zbarsky" <bzbarsky at MIT.EDU> wrote:

>On 1/27/11 4:48 AM, Brett Zamir wrote:
>> I was thinking of it grabbing the "winning" property for the whole
>> document, i.e., the one which would be applicable without knowing
>> contextual information. So, if the selector specified were ".error",
>> wouldn't get "div.error"
>That's pretty difficult to define, actually.  Should it get
>> Whatever the rules, it would be the team's responsibility to ensure
>> was unique enough to provide the right value (as it is within CSS
>> via cascading).
>Why is just asking for computed style, and getting correct answers that
>include the results of the cascade, not the right solution here?

Without context you can't get the cascading or "winning" values for css attributes. You could create a whole pseudo document to get this, but it is needlessly complex. You say you would want .error to not get matched by div.error, but in a real document the order of the styles and the weight of them (id's over classes, !important rules, etc) dictate the final style attributes.

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

More information about the whatwg mailing list