element.style

  • Revision slug: Talk:DOM/element.style
  • Revision title: element.style
  • Revision id: 127147
  • Created:
  • Creator: RobG
  • Is current revision? No
  • Comment Discussion of style attribute/object

Revision Content

The description ot the style property does not seem correct.

From the W3C DOM 2 reference (Section 1.6.4):

  "The style attribute of an HTML element is accessible through the
    ElementCSSInlineStyle interface which is defined in the CSS module
    [DOM Level 2 Style Sheets and CSS]."

   <URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-011100101>


Following that link makes me think that the style attribute of an HTML element is part of the CSS2 extended interface:

  "The CSS2Properties interface represents a convenience mechanism
    for retrieving and setting properties within a CSSStyleDeclaration."

  <URL:http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-extended>


and that it is not a 'block' but an object with proerties that can be changed. The current description is:

  "Returns the block of style rules on the element."


maybe is should be:

  "Returns the style object of the element."


In the notes section it states:

  "though you cannot set style on an element by assigning to the style
   property directly"


Which is also incorrect. Style properties can be set directly, however the affect of setting them must be considered within the context of cascading styles and specificity (i.e. their affect may be over–ridden by some other style rule).

I'll leave this comment here for a while, if there is no indication to the contrary, I'll go ahead and make changes.

Revision Source

<p>The description ot the style property does not seem correct.  
</p><p>From the W3C DOM 2 reference (Section 1.6.4):
</p>
<pre>  "The style attribute of an HTML element is accessible through the
    ElementCSSInlineStyle interface which is defined in the CSS module
    [DOM Level 2 Style Sheets and CSS]."

   &lt;URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-011100101&gt;
</pre>
<p><br>
Following that link makes me think that the style attribute of an HTML element is part of the CSS2 extended interface:
</p>
<pre>  "The CSS2Properties interface represents a convenience mechanism
    for retrieving and setting properties within a CSSStyleDeclaration."

  &lt;URL:http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-extended&gt;
</pre>
<p><br>
and that it is not a 'block' but an object with proerties that can be changed.  The current description is:
</p>
<pre>  "Returns the block of style rules on the element."
</pre>
<p><br>
maybe is should be:
</p>
<pre>  "Returns the style object of the element."
</pre>
<p><br>
In the notes section it states:
</p>
<pre>  "though you cannot set style on an element by assigning to the style
   property directly"
</pre>
<p><br>
Which is also incorrect.  Style properties <b>can</b> be set directly, however the affect of setting them must be considered within the context of cascading styles and specificity (i.e. their affect may be over–ridden by some other style rule).
</p><p>I'll leave this comment here for a while, if there is no indication to the contrary, I'll go ahead and make changes.
</p>
Revert to this revision