Represents the current settings of all possible inline styles for a given element.
Members
The style object has these types of members:
Methods
The style object has these methods.
| Method | Description |
|---|---|
| getAttribute |
Retrieves the value of the specified attribute. |
| getAttributeNode |
Retrieves an attribute object referenced by the attribute.name property. |
| getPropertyPriority |
Gets the priority of a CSS property if the priority is explicitly set in the current declaration block. |
| getPropertyValue |
Gets the value of a CSS property if it is explicitly set within the current declaration block. |
| hasAttribute |
Determines whether an attribute with the specified name exists. |
| hasAttributes |
Determines whether one or more attributes exist for the object. |
| item |
Gets a property that has been explicitly set in the current declaration block. |
| msGetPropertyEnabled |
Returns whether a given property in the style object is enabled. |
| msPutPropertyEnabled |
Sets whether a given property in the style object is enabled. |
| normalize |
Merges adjacent DOM objects to produce a normalized document object model. |
| removeAttribute |
Removes an attribute from an object. |
| removeAttributeNode |
Removes an attribute object from the object. |
| removeProperty |
Removes a CSS property if it is explicitly set within the current declaration block. |
| setAttribute |
Sets the value of the specified attribute. |
| setAttributeNode |
Sets an attribute object node as part of the object. |
| setProperty |
Sets a property value and priority within the current declaration block. |
Properties
The style object has these properties.
| Property | Description |
|---|---|
|
Sets or retrieves a string that indicates whether the object represents a keyboard shortcut. | |
|
Specifies one or more shorthand values that define all animation properties (except animation-play-state) for a set of corresponding object properties identified in the CSS @keyframes at-rule specified by the animations-name property. | |
|
Specifies the offset within an animation cycle (the amount of time from the start of a cycle) before the animation is displayed for a set of corresponding object properties identified in the CSS @keyframes at-rule specified by the animation-name property. | |
|
Specifies the direction of play for an animation cycle. | |
|
Specifies the length of time to complete one cycle of the animation. | |
|
Specifies whether the effects of an animation are visible before or after it plays. | |
|
Specifies the number of times an animation cycle is played. | |
|
Identifies one or more animation names. An animation name selects a CSS @keyframes at-rule. | |
|
Specifies whether an animation is playing or paused. | |
|
Specifies the intermediate property values to be used during a single cycle of an animation on a set of corresponding object properties identified in the CSS @keyframes at-rule specified by the animation-name property. | |
|
Retrieves a collection of attributes of the object. | |
|
Gets or sets a value that specifies whether the back face (reverse side) of an object is visible. | |
|
Specifies up to five separate background properties of an object. | |
|
Specifies how the background image (or images) is attached to the object within the document. | |
|
Specifies the background painting area or areas relative to the element's bounding boxes. | |
|
Specifies the background painting area or areas relative to the element's bounding boxes. | |
|
Specifies the background painting area or areas relative to the element's bounding boxes. | |
|
Specifies the color behind the content of the object. | |
|
Specifies the background image or images of the object. | |
|
Specifies the positioning area of an element or multiple elements. | |
|
Specifies the positioning area of an element or multiple elements. | |
|
Specifies the position of the background of the object. | |
|
The x-coordinate of the background-position property. | |
|
The y-coordinate of the background-position property. | |
|
Specifies whether and how the background image (or images) is tiled. | |
|
Specifies the size of the background images. | |
|
Specifies the size of the background images. | |
|
Sets or retrieves a value that indicates how the dominant baseline should be repositioned relative to the dominant baseline of the parent text content element. | |
|
Sets or retrieves the location of the Dynamic HTML (DHTML) behaviorDHTML Behaviors. | |
|
Specifies the properties of a border drawn around an object. | |
|
Specifies the properties of the bottom border of the object. | |
|
Specifies the foreground color of the bottom border of an object. | |
|
Specifies the radii of the quarter ellipse that defines the shape of the lower-left corner for the outer border edge of the current box. | |
|
Sets or retrieves one or two values that define the radii of the quarter ellipse that defines the shape of the lower-right corner for the outer border edge of the current box. | |
|
Specifies the style of the bottom border of the object. | |
|
Specifies the thickness of the bottom border of the object. | |
|
Indicates whether the row and cell borders of a table are joined in a single border or detached as in standard HTML. | |
|
Specifies the border color of the object. | |
|
Specifies the properties of the left border of the object. | |
|
Specifies the foreground color of the left border of an object. | |
|
Sets or retrieves the style of the left border of the object. | |
|
Specifies the thickness of the left border of the object. | |
|
Specifies the radii of a quarter ellipse that defines the shape of the corners for the outer border edge of the current box. | |
|
Specifies the properties of the right border of the object. | |
|
Specifies the foreground color of the right border of an object. | |
|
Specifies the style of the right border of the object. | |
|
Specifies the thickness of the right border of the object. | |
|
Specifies the distance between the borders of adjoining cells in a table. | |
|
Specifies the style of the left, right, top, and bottom borders of the object. | |
|
Specifies the properties of the top border of the object. | |
|
Specifies the foreground color of the top border of an object. | |
|
Sets or retrieves one or two values that define the radii of the quarter ellipse that defines the shape of the upper-left corner for the outer border edge of the current box. | |
|
Sets or retrieves one or two values that define the radii of the quarter ellipse that defines the shape of the upper-right corner for the outer border edge of the current box. | |
|
Specifies the style of the top border of the object. | |
|
Specifies the thickness of the top border of the object. | |
|
Specifies the thicknesses of the left, right, top, and bottom borders of an object. | |
|
Sets or retrieves the bottom position of the object in relation to the bottom of the next positioned object in the document hierarchy. | |
|
Specifies one or more set of shadow values that attaches one or more drop shadows to the current box. | |
|
Sets or retrieves the box model to use for object sizing. | |
|
Gets or sets the column-break behavior that follows a content block in a multi-column element. | |
|
Gets or sets the column-break behavior that precedes a content block in a multi-column element. | |
|
Gets or sets the column-break behavior that occurs within a content block in a multi-column element. | |
|
Specifies whether the object allows floating objects on its left side, right side, or both, so that the next text displays past the floating objects. | |
|
Specifies which part of a positioned object is visible. | |
|
Gets the bottom coordinate of the object clipping region. | |
|
Gets the left coordinate of the object clipping region. | |
|
Sets or retrieves a reference to the SVG graphical object that will be used as the clipping path. | |
|
Gets the right coordinate of the object clipping region. | |
|
Gets the top coordinate of the object clipping region. | |
|
The foreground color of the text of an object. | |
|
Gets or sets the optimal number of columns in a multi-column element. | |
|
Gets or sets a value that indicates how the column lengths in a multi-column element are affected by the content flow. | |
|
Gets or sets the width of the gap between columns in a multi-column element. | |
|
Gets or sets a shorthand value that specifies values for the columnRuleWidth, columnRuleStyle, and the columnRuleColor of a multi-column element. | |
|
Gets or sets the color for all column rules in a multi-column element. | |
|
Gets or sets the style for all column rules in a multi-column element. | |
|
Gets or sets the width of all column rules in a multi-column element. | |
|
Gets or sets the number of columns that a content block spans in a multi-column element. | |
|
Gets or sets the optimal width of the columns in a multi-column element. | |
|
Returns a reference to the constructor of an object. | |
|
Sets or retrieves generated content to insert before or after an element. | |
|
Sets or retrieves a list of counters to increment. | |
|
Sets or retrieves a list of counters to create or reset to zero. | |
|
Sets or retrieves a value that specifies whether a box should float to the left, right, or not at all. | |
|
Sets or retrieves the persisted representation of the style rule. | |
|
Specifies the type of cursor to display as the mouse pointer moves over the object. | |
|
Specifies the reading order of the object. | |
|
Gets or sets a value that indicates whether and how the object is rendered. | |
|
Sets or retrieves a value that determines or redetermines a scaled-baseline table. | |
|
Determines whether to show or hide a cell without content. | |
|
Sets or retrieves a value that indicates the color to paint the interior of the given graphical element. | |
|
Sets or retrieves a value that specifies the opacity of the painting operation that is used to paint the interior of the current object. | |
|
Sets or retrieves a value that indicates the algorithm that is to be used to determine what parts of the canvas are included inside the shape. | |
|
Sets or retrieves a combination of separate font properties of the object. Alternatively, sets or retrieves one or more of six user-preference fonts. | |
|
Sets or retrieves the name of the font used for text in the object. | |
|
Sets or retrieves a value that indicates the font size used for text in the object. | |
|
Sets or retrieves a value that specifies an aspect value for an element that will effectively preserve the x-height of the first choice font, whether it is substituted or not. | |
|
Sets or retrieves a value that indicates a normal, condensed, or expanded face of a font family. | |
|
Sets or retrieves a value that indicates a normal, condensed, or expanded face of a font family. | |
|
Sets or retrieves the font style of the object as italic, normal, or oblique. | |
|
Gets or sets whether the text of the object is in small capital letters. | |
|
Gets of sets the weight of the font of the object. | |
|
Sets or retrieves a value that alters the orientation of a sequence of characters relative to an inline-progression-direction of horizontal. | |
|
Sets or retrieves a value that alters the orientation of a sequence of characters relative to an inline-progression-direction of vertical. | |
|
Sets or retrieves the height of the object. | |
|
Sets or retrieves the state of an IME. | |
|
Gets or sets a value that indicates whether Windows Store app using JavaScript should adjust inter-glyph spacing based on kerning tables that are included in the relevant font (that is, enable auto-kerning) or instead disable auto-kerning and set inter-character spacing to a specific length (typically zero). | |
|
Sets or retrieves the composite document grid properties that specify the layout of text characters. | |
|
Sets or retrieves the size of the character grid used for rendering the text content of an element. | |
|
Sets or retrieves the gridline value used for rendering the text content of an element. | |
|
Gets or sets whether the text layout grid uses two dimensions. | |
|
Sets or retrieves the type of grid used for rendering the text content of an element. | |
|
Sets or retrieves the position of the object relative to the left edge of the next positioned object in the document hierarchy. | |
|
Retrieves the number of properties that are explicitly set on the parent object. | |
|
Sets or retrieves the amount of additional space between letters in the object. | |
|
Sets or retrieves the distance between lines in the object. | |
|
Sets or retrieves up to three separate list-style properties of the object. | |
|
Sets or retrieves a value that indicates which image to use as a list-item marker for the object. | |
|
Sets or retrieves a variable that indicates how the list-item marker is drawn relative to the content of the object. | |
|
Sets or retrieves the predefined type of the line-item marker for the object. | |
|
Sets or retrieves the width of the top, right, bottom, and left margins of the object. | |
|
Sets or retrieves the height of the bottom margin of the object. | |
|
Sets or retrieves the width of the left margin of the object. | |
|
Sets or retrieves the width of the right margin of the object. | |
|
Sets or retrieves the height of the top margin of the object. | |
|
Sets or retrieves a value that specifies the marker symbol that is used for all vertices on the given path element or basic shape. | |
|
Sets or retrieves a value that defines the arrowhead or polymarker that is drawn at the final vertex of a given path element or basic shape. | |
|
Sets or retrieves a value that defines the arrowhead or polymarker that is drawn at every other vertex (that is, every vertex except the first and last) of a given path element or basic shape. | |
|
Sets or retrieves a value that defines the arrowhead or polymarker that is drawn at the first vertex of a given path element or basic shape. | |
|
Sets or retrieves a value that indicates a SVG mask. | |
|
Sets or retrieves the maximum height for an element. | |
|
Sets or retrieves the maximum width for an element. | |
|
Sets or retrieves the minimum height for an element. | |
|
Sets or retrieves the minimum width for an element. | |
|
Sets or retrieves the block progression and layout orientation. | |
|
Gets or sets a value that specifies in which column of the grid to place the object. | |
|
Gets or sets a value that specifies the horizontal alignment of the object within the grid column. | |
|
Gets or sets one or more values that specify the width of each grid column within the object. | |
|
Gets or sets a value that specifies the number of columns of the grid that the object spans. | |
|
Gets or sets a value that specifies in which row of the grid to place the object. | |
|
Gets or sets a value that specifies the vertical alignment of the object within the grid row. | |
|
Gets or sets one or more values that specify the height of each grid row within the object. | |
|
Gets or sets a value that specifies the number of rows of the grid that the object spans. | |
|
This property is obsolete. Use animation-name instead. | |
|
Gets or sets a value that specifies object or group opacity in CSS or SVG. | |
|
Sets or retrieves the minimum number of lines of a paragraph that must appear at the bottom of a page. | |
|
Sets or retrieves the color, style, and width of the outline frame. | |
|
Sets or retrieves the color of the outline frame. | |
|
Sets or retrieves the style of the outline frame. | |
|
Sets or retrieves the width of the outline frame. | |
|
Sets or retrieves a value indicating how to manage the content of the object when the content exceeds the height or width of the object. | |
|
Sets or retrieves how to manage the content of the object when the content exceeds the width of the object. | |
|
Sets or retrieves how to manage the content of the object when the content exceeds the height of the object. | |
|
Sets or retrieves the amount of space to insert between the object and its margin or, if there is a border, between the object and its border. | |
|
Sets or retrieves the amount of space to insert between the bottom border of the object and the content. | |
|
Sets or retrieves the amount of space to insert between the left border of the object and the content. | |
|
Sets or retrieves the amount of space to insert between the right border of the object and the content. | |
|
Sets or retrieves the amount of space to insert between the top border of the object and the content. | |
|
Sets or retrieves a value indicating whether a page break occurs after the object. | |
|
Sets or retrieves a string indicating whether a page break occurs before the object. | |
|
Sets or retrieves a string indicating whether a page break is allowed to occur inside the object. | |
|
Retrieves the containing rule, if the current rule is contained inside another rule. | |
|
Gets or sets a value that represents the perspective from which all child elements of the object are viewed. | |
|
Gets or sets one or two values that represent the origin (the vanishing point for the 3-D space) of an object with an perspective property declaration. | |
|
Sets or retrieves the bottom position of the object. | |
|
Sets or retrieves the height of the object. | |
|
Sets or retrieves the left position of the object. | |
|
Sets or retrieves the right position of the object. | |
|
Sets or retrieves the top position of the object. | |
|
Sets or retrieves the width of the object. | |
|
Sets or retrieves a value that specifies under what circumstances a given graphics element can be the target element for a pointer event in SVG. | |
|
Sets or retrieves the bottom position of the object in the units specified by the bottom attribute. | |
|
Sets or retrieves the height of the object in the units specified by the height attribute. | |
|
Sets or retrieves the type of positioning used for the object. | |
|
Sets or retrieves the left position of the object in the units specified by the left attribute. | |
|
Sets or retrieves the right position of the object in the units specified by the right attribute. | |
|
Sets or retrieves the top position of the object in the units specified by the top attribute. | |
|
Sets or retrieves the width of the object in the units specified by the width attribute. | |
|
Sets or retrieves the pairs of strings to be used as quotes in generated content. | |
|
Sets or retrieves the position of the object relative to the right edge of the next positioned object in the document hierarchy. | |
|
Sets or retrieves the role for this element. | |
|
Gets or sets a value that indicates how to align the ruby text content. | |
|
Gets or sets a value that indicates whether, and on which side, ruby text is allowed to partially overhang any adjacent text in addition to its own base, when the ruby text is wider than the ruby base | |
|
Gets or sets a value that controls the position of the ruby text with respect to its base. | |
|
Sets or retrieves the color of the top and left edges of the scroll box and scroll arrows of a scroll bar. | |
|
Sets or retrieves the color of the arrow elements of a scroll arrow. | |
|
Sets or retrieves the color of the main elements of a scroll bar, which include the scroll box, track, and scroll arrows. | |
|
Sets or retrieves the color of the gutter of a scroll bar. | |
|
Sets or retrieves the color of the scroll box and scroll arrows of a scroll bar. | |
|
Sets or retrieves the color of the top and left edges of the scroll box and scroll arrows of a scroll bar. | |
|
Sets or retrieves the color of the bottom and right edges of the scroll box and scroll arrows of a scroll bar. | |
|
Sets or retrieves the color of the track element of a scroll bar. | |
|
Sets or retrieves a value that indicates what color to use at the current gradient stop. | |
|
Sets or retrieves a value that defines the opacity of the current gradient stop. | |
|
Sets or retrieves a value that indicates the color to paint along the outline of a given graphical element. | |
|
Sets or retrieves one or more values that indicate the pattern of dashes and gaps used to stroke paths. | |
|
Sets or retrieves a value that specifies the distance into the dash pattern to start the dash. | |
|
Sets or retrieves a value that specifies the shape to be used at the end of open subpaths when they are stroked. | |
|
Sets or retrieves a value that specifies the shape to be used at the corners of paths or basic shapes when they are stroked. | |
|
Sets or retrieves a value that indicates the limit on the ratio of the length of miter joins (as specified in the strokeLinejoin property). | |
|
Sets or retrieves a value that specifies the opacity of the painting operation that is used to stroke the current object. | |
|
Sets or retrieves a value that specifies the width of the stroke on the current object. | |
|
Sets or retrieves on which side of the object the text will flow. | |
|
Sets or retrieves a string that indicates whether the table layout is fixed. | |
|
Sets or retrieves whether the text in the object is left-aligned, right-aligned, centered, or justified. | |
|
Gets or sets a value that indicates how to align the last line or only line of text in the specified object. | |
|
Sets or retrieves the autospacing and narrow space width adjustment of text. | |
|
Sets or retrieves a value that indicates whether the text in the object has blink, line-through, overline, or underline decorations. | |
|
Sets or retrieves a Boolean value indicating whether the text in the object has a line drawn through it. | |
|
Sets or retrieves the Boolean value indicating whether the textDecoration property for the object has been set to none. | |
|
Sets or retrieves a Boolean value indicating whether the text in the object has a line drawn over it. | |
|
Sets or retrieves whether the text in the object is underlined. | |
|
Sets or retrieves the indentation of the first line of text in the object. This property is not supported for Windows Store apps using JavaScript. | |
|
Sets or retrieves the type of alignment used to justify text in the object. | |
|
Sets or retrieves a value that indicates whether to render ellipses (...) to indicate text overflow. | |
|
Sets or retrieves the rendering of the text in the object. | |
|
Sets or retrieves the position of the underline decoration that is set through the text-decoration property of the object. | |
|
Sets or retrieves the position of the object relative to the top of the next positioned object in the document hierarchy. | |
|
Gets or sets a list of one or more transform functions that specify how to translate, rotate, or scale an element in 2-D or 3-D space. | |
|
Gets or sets one or two values that establish the origin of transformation for an element. | |
|
Gets or sets a value that specifies how child elements of the object are rendered in 3-D space. | |
|
Gets or sets one or more shorthand values that specify the transition properties for a set of corresponding object properties identified in the transition-property property. | |
|
Gets or sets one or more values that specify the offset within a transition (the amount of time from the start of a transition) before the transition is displayed for a set of corresponding object properties identified in the transition property. | |
|
Gets or sets one or more values that specify the durations of transitions on a set of corresponding object properties identified in the transition-property property. | |
|
Gets or sets a value that identifies the CSS property name or names to which the transition effect (defined by the transition-duration, transition-timing-function, and transition-delay properties) is applied when a new property value is specified. | |
|
Gets or sets one or more values that specify the intermediate property values to be used during a transition on a set of corresponding object properties identified in the transition-property property. | |
|
Specifies the level of embedding with respect to the bidirectional algorithm. | |
|
Sets or retrieves the vertical alignment of the object. | |
|
Sets or retrieves whether the content of the object is displayed. | |
|
Sets or retrieves a value that indicates whether lines are automatically broken inside the object. | |
|
Sets or retrieves the minimum number of lines of a paragraph that must appear at the top of a document. | |
|
Sets or retrieves the width of the object. | |
|
Sets or retrieves line-breaking behavior within words, particularly where multiple languages appear in the object. | |
|
Sets or retrieves the amount of additional space between words in the object. | |
|
Sets or retrieves whether to break words when the content exceeds the boundaries of its container. | |
|
Specifies the direction and flow of the content in the object. | |
|
Sets or retrieves the stacking order of positioned objects. | |
|
Sets or retrieves the magnification scale of the object. |
Standards information
There are no standards that apply here.
Remarks
Inline styles are CSS assignments that you apply directly to individual HTML elements using the STYLE attribute. Use the style object to examine these assignments and to make new assignments or change existing ones.
To retrieve the style object, apply the style keyword to an element object. To retrieve the current setting for an inline style, apply the corresponding style property to the style object.
The style object does not provide access to the style assignments in style sheets. To obtain information about styles in style sheets, use the styleSheets collection to access to the individual style sheets defined in the document.
The following properties are not available when the rule object accesses the style object: posHeight, posWidth, posTop, posLeft, pixelHeight, pixelWidth, pixelTop, and pixelLeft.
To change or clear multiple style properties simultaneously, use this object with the cssText property. For example, to change the font color and background color of a DIV element, you could use the following code:
<DIV onclick="this.style.cssText = 'color:red;background-color:blue;border:5px solid black;'"> Click this DIV to change style properties.</DIV>
Examples
This example uses the style object to set the document body text font to Verdana.
document.body.style.fontFamily = "Verdana"
This example positions all absolutely positioned images in the given document at the top of the document.
var oImages = document.all.tags("IMG");
if (oImages.length) {
for (var iImg = 0; iImg < oImages.length; iImg++) {
var oImg = oImages(iImg);
if (oImg.style.position == "absolute") {
oImg.style.top = 0;
}
}
}
This example copies the inline style of the second element (div2) to the first (div1) while preserving the styles of the second. The background color of div1 is overwritten during the assignment.
<DIV ID="div1" STYLE="background-color:blue;font-weight:bold">Item 1</DIV>
<DIV ID="div2" STYLE="background-color:red;font-size:18pt;
font-family:Verdana;">Item 2</DIV>
<SCRIPT>
div1.style.cssText += (';' + div2.style.cssText);
</SCRIPT>
Build date: 11/29/2012