Where is the javascript HTMLElement.style.property=value syntax specified?

I'm having a little trouble finding the specification for the syntax

HTMLElement.style.property=”value” // set the property value

I see this syntax frequently used (and have used it myself successfully) but cannot find a specification that allows this syntax.

An example of the use of this syntax is at: http://www.w3schools.com/jsref/dom_obj_style.asp and at https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.style but I cannot seem to find the syntax in the CSSOM specification: http://dev.w3.org/csswg/cssom/

The CSSOM specifies an HTMLElement interface of

HTMLElement implements ElementCSSInlineStyle;

where ElementCSSInlineStyle is

 interface ElementCSSInlineStyle {
     [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;

and where CSSStyleDaeclaration is

 interface CSSStyleDeclaration {
     attribute DOMString cssText;
     readonly attribute unsigned long length;
     getter DOMString item(unsigned long index);
     DOMString getPropertyValue(DOMString property);
     DOMString getPropertyPriority(DOMString property);
     void setProperty(DOMString property, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
     void setPropertyValue(DOMString property, [TreatNullAs=EmptyString] DOMString value);
     void setPropertyPriority(DOMString property, [TreatNullAs=EmptyString] DOMString priority);
     DOMString removeProperty(DOMString property);
     readonly attribute CSSRule? parentRule;
     attribute DOMString cssFloat;

Maybe I'm missing something fundamental but it doesn't look to me if the syntax in question is allowed by the specification. If anyone has a reference to the syntax that allows the direct setting of a style property I'd appreciate receiving it.


It's indeed in the CSSOM spec for the CSSStyleDeclaration, right under the cssFloat attribute:

For each CSS property property that is a supported CSS property, the following partial interface applies where camel-cased attribute is obtained by running the CSS property to IDL attribute algorithm for property.

partial interface CSSStyleDeclaration {
           attribute DOMString _camel-cased attribute;

The camel-cased attribute attribute, on getting, must return the result of invoking getPropertyValue() with the argument being the result of running the IDL attribute to CSS property algorithm for camel-cased attribute.

Setting the camel-cased attribute attribute must invoke setProperty() with the first argument being the result of running the IDL attribute to CSS property algorithm for camel-cased attribute, as second argument the given value, and no third argument. Any exceptions thrown must be re-thrown.

That way, they worked around declaring each single supported property as an own IDL attribute.

Need Your Help

How to programmatically EraseByPoint on an InkCanvas/StrokeCollection?

c# wpf signalr inkcanvas

I am creating a Signal R app that has a drawing section on the UI, right now I am working on the WPF client but there will eventually be a MVC and Android client as well.

Convert unix timestamp to date without system libs

c date timestamp embedded

I am building a embedded project which displays the time retrieved from a GPS module on a display, but I would also like to display the current date. I currently have the time as a unix time stamp ...