O'Reilly logo

Dynamic HTML: The Definitive Reference by Danny Goodman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

style — NN n/a IE 4 DOM 1

Synopsis

Almost every object that reflects an HTML element has a style object associated with it (as you can see from the style property that pervades the object listings in this chapter). The style object reflects the STYLE attribute set in the element’s tag. If the element is under the influence of a style sheet rule that is set in a STYLE element (assigned to a selector that applies to the current element), those style sheet values are not part of the style object. Even if the element is under the influence of one of these distant style sheet rules, you can still assign a value to any style object property for any element: the setting is likely to override (by virtue of the cascading rules described in Chapter 3) styles assigned from a STYLE element.

From a scripting point of view, it is important to know that while a style object’s property exhibits a default behavior (a font size or alignment, for example), the default value may not be reflected in the property unless the value has been explicitly set in the element tag’s STYLE attribute or assigned by another script statement. The Macintosh version of Internet Explorer 4 is a bit better in exposing default values, but by and large, a style object’s property default value is an empty string or null. Therefore, do not expect condition testing to necessarily reveal the current value of a property unless it has been set previously.

The properties of the style object correspond to the CSS attributes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required