Table of Contents | Previous
| Next
| Index
An object that specifies the style of HTML elements.
Any of the following properties or methods of the document object:
The Style object lets you implement dynamic HTML style sheets in JavaScript. The methods and properties of the Style object implement the cascading style sheet style properties of HTML in JavaScript.
For a complete description of style sheets, see Dynamic HTML in Netscape Communicator.
|
Property
|
Description
align
|
Specifies the alignment of an HTML element within its parent.
| backgroundColor
|
Specifies a solid background color for an element.
| backgroundImage
|
Specifies a background image for an HTML element.
| borderBottomWidth
|
Specifies the width of the bottom border of an HTML element.
| borderColor
|
Specifies the color of the border of an HTML element.
| borderLeftWidth
|
Specifies the width of the left border of an HTML element.
| borderRightWidth
|
Specifies the width of the right border of an HTML element.
| borderStyle
|
Specifies the style of border, such as solid or double, around a block-level HTML element.
| borderTopWidth
|
Specifies the width of the top border of an HTML element.
| clear
|
Specifies the sides of an HTML element that allow floating elements.
| color
|
Specifies the color of the text in an HTML element.
| display
|
Overrides the usual display of an element and specifies whether the element appears in line, as a block-level element, or as a block-level list item.
| fontFamily
|
Specifies the font family, such as Helvetica or Arial, for an HTML text element.
| fontSize
|
Specifies the font size for an HTML text element.
| fontStyle
|
Specifies the style of the font of an HTML element.
| fontWeight
|
Specifies the weight of the font of an HTML element.
| lineHeight
|
Specifies the distance between the baselines of two adjacent lines of block-level type.
| listStyleType
|
Specifies the style of bullet displayed for list items.
| marginBottom
|
Specifies the minimal distance between the bottom of an HTML element and the top of an adjacent element.
| marginLeft
|
Specifies the minimal distance between the left side of an HTML element and the right side of an adjacent element.
| marginRight
|
Specifies the minimal distance between the right side of an HTML element and the left side of an adjacent element.
| marginTop
|
Specifies the minimal distance between the top of an HTML element and the bottom of an adjacent element.
| paddingBottom
|
Specifies how much space to insert between the bottom of an element and its content, such as text or an image.
| paddingLeft
|
Specifies how much space to insert between the left side of an element and its content, such as text or an image.
| paddingRight
|
Specifies how much space to insert between the right side of an element and its content, such as text or an image.
| paddingTop
|
Specifies how much space to insert between the top of an element and its content, such as text or an image.
| textAlign
|
Specifies the alignment of an HTML block-level text element.
| textDecoration
|
Specifies special effects, such as blinking, strike-outs, and underlines, added to an HTML text element.
| textIndent
|
Specifies the length of indentation appearing before the first formatted line of a block-level HTML text element.
| textTransform
|
Specifies the case of an HTML text element.
| whiteSpace
|
Specifies whether or not white space within an HTML element should be collapsed.
| width
|
Specifies the width of a block-level HTML element.
| |
|---|
In addition, this object inherits the watch and unwatch methods from Object.
Specifies the alignment of an HTML element within its parent.
styleObject.align = {left | right | none}
Do not confuse align with textAlign, which specifies the alignment of the content of text elements.
The align property is a reflection of the cascading style sheet float property.
Specifies a solid background color for an element.
styleObject.backgroundColor = colorValue
The backgroundColor property is a reflection of the cascading style sheet background-color property.
Specifies a background image for an HTML element.
styleObject.backgroundImage = url
The backgroundImage property is a reflection of the cascading style sheet background-image property.
Specifies the width of the bottom border of an HTML element.
styleObject.borderBottomWidth = length
The borderBottomWidth property is a reflection of the cascading style sheet border-bottom-width property.
Style.borderLeftWidth, Style.borderRightWidth, Style.borderTopWidth, Style.borderWidths
Specifies the color of the border of an HTML element.
styleObject.borderColor = {none | colorValue}
The borderColor property is a reflection of the cascading style sheet border-color property.
Specifies the width of the left border of an HTML element.
styleObject.borderLeftWidth = length
The borderLeftWidth property is a reflection of the cascading style sheet border-left-width property.
Style.borderBottomWidth, Style.borderRightWidth, Style.borderTopWidth, Style.borderWidths
Specifies the width of the right border of an HTML element.
styleObject.borderRightWidth = length
The borderRightWidth property is a reflection of the cascading style sheet border-right-width property.
Style.borderBottomWidth, Style.borderLeftWidth, Style.borderTopWidth, Style.borderWidths
Specifies the style of border, such as solid or double, around a block-level HTML element.
styleObject.borderStyle = styleType
You must also specify a border width for the border to be visible.
The borderStyle property is a reflection of the cascading style sheet border-style property.
Specifies the width of the top border of an HTML element.
styleObject.borderTopWidth = length
The borderTopWidth property is a reflection of the cascading style sheet border-top-width property.
Style.borderBottomWidth, Style.borderLeftWidth, Style.borderRightWidth, Style.borderWidths
Specifies the width of the borders of an HTML element.
borderWidths(top, right, bottom, left)
The borderWidths method is a convenience shortcut for setting all the border width properties.
Style.borderBottomWidth, Style.borderLeftWidth, Style.borderRightWidth, Style.borderTopWidth
Specifies the sides of an HTML element that allow floating elements.
styleObject.clear = {left | right | both | none}
The clear property is a reflection of the cascading style sheet clear property.
Specifies the color of the text in an HTML element.
styleObject.color = colorValue
The color property is a reflection of the cascading style color property.
Overrides the usual display of an element and specifies whether the element appears in line, as a block-level element, or as a block-level list item.
styleObject.display = styleType
The display property is a reflection of the cascading style display property.
Specifies the font family, such as Helvetica or Arial, for an HTML text element.
styleObject.fontFamily = {specificFamily | genericFamily}
The fontFamily property is a reflection of the cascading style sheet font-family property. The genericFamily keywords are available for all platforms, but the specific font displayed varies on each platform.
You can mix the specificFamily and genericFamily keywords in the same value. For example, the following code displays text in Helvetica if that font is available; otherwise, the text displays in a sans-serif font determined by the operating system:
document.tags.H1.fontFamily = "Helvetica, sans-serif"
You can also link to a font definition file and download it when a browser loads the web page, guaranteeing that all the fonts are available on a user's system. See Dynamic HTML in Netscape Communicator.
Specifies the font size for an HTML text element.
styleObject.fontSize =
{absoluteSize | relativeSize | length | percentage}
The fontSize property is a reflection of the cascading style sheet font-size property. By default, the initial value is medium.
Specifies the style of the font of an HTML element.
styleObject.fontStyle = styleType
The fontStyle property is a reflection of the cascading style sheet font-style property.
Specifies the weight of the font of an HTML element.
styleObject.fontWeight = {absolute | relative | numeric}
The fontWeight property is a reflection of the cascading style sheet font-weight property.
Specifies the distance between the baselines of two adjacent lines of block-level type.
styleObject.lineHeight = {number | length | percentage | normal}
The lineHeight property is a reflection of the cascading style sheet line-height property.
When you set the lineHeight property by specifying number, Navigator calculates the line height by multiplying the font size of the current element by number. For example, if lineHeight is set to 1.2 in a paragraph using a 10-point font, the line height is 12 points.
When you set lineHeight with number, children of the current paragraph inherit the line height factor; when you set lineHeight with length or percentage, children inherit the resulting value.
Specifies the style of bullet displayed for list items.
styleObject.listStyleType = styleType
The listStyleType property is a reflection of the cascading style sheet list-style-type property.
Specifies the minimal distance between the bottom of an HTML element and the top of an adjacent element.
styleObject.marginBottom = {length | percentage | auto}
The marginBottom property is a reflection of the cascading style sheet margin-bottom property.
Style.marginLeft, Style.marginRight, Style.marginTop, Style.margins
Specifies the minimal distance between the left side of an HTML element and the right side of an adjacent element.
styleObject.marginLeft = {length | percentage | auto}
The marginLeft property is a reflection of the cascading style sheet margin-left property.
Style.marginBottom, Style.marginRight, Style.marginTop, Style.margins
Specifies the minimal distance between the right side of an HTML element and the left side of an adjacent element.
styleObject.marginRight = {length | percentage | auto}
The marginRight property is a reflection of the cascading style sheet margin-right property.
Style.marginBottom, Style.marginLeft, Style.marginTop, Style.margins
Specifies the minimal distance between the sides of an HTML element and the sides of adjacent elements.
margins(top, right, bottom, left)
The margins method is a convenience shortcut for setting all the margin properties.
Style.marginBottom, Style.marginLeft, Style.marginRight, Style.marginTop
Specifies the minimal distance between the top of an HTML element and the bottom of an adjacent element.
styleObject.marginTop = {length | percentage | auto}
The marginTop property is a reflection of the cascading style sheet margin-top property.
Style.marginBottom, Style.marginLeft, Style.marginRight, Style.margins
Specifies how much space to insert between the bottom of an element and its content, such as text or an image.
styleObject.paddingBottom = {length | percentage}
The paddingBottom property is a reflection of the cascading style sheet padding-bottom property.
Style.paddingLeft, Style.paddingRight, Style.paddingTop, Style.paddings
Specifies how much space to insert between the left side of an element and its content, such as text or an image.
styleObject.paddingLeft = {length | percentage}
The paddingLeft property is a reflection of the cascading style sheet padding-left property.
Style.paddingBottom, Style.paddingRight, Style.paddingTop, Style.paddings
Specifies how much space to insert between the right side of an element and its content, such as text or an image.
styleObject.paddingRight = {length | percentage}
The paddingRight property is a reflection of the cascading style sheet padding-right property.
Style.paddingBottom, Style.paddingLeft, Style.paddingTop, Style.paddings
Specifies how much space to insert between the sides of an element and its content, such as text or an image.
paddings(top, right, bottom, left)
The paddings method is a convenience shortcut for setting all the padding properties.
Style.paddingBottom, Style.paddingLeft, Style.paddingRight, Style.paddingTop
Specifies how much space to insert between the top of an element and its content, such as text or an image.
styleObject.paddingTop = {length | percentage}
The paddingTop property is a reflection of the cascading style sheet padding-top property.
Style.paddingBottom, Style.paddingLeft, Style.paddingRight, Style.paddings
Specifies the alignment of an HTML block-level text element.
styleObject.textAlign = alignment
Do not confuse textAlign with align, which specifies the alignment of an HTML element within its parent.
The textAlign property is a reflection of the cascading style sheet text-align property.
Specifies special effects, such as blinking, strike-outs, and underlines, added to an HTML text element.
styleObject.textDecoration = decoration
The textDecoration property is a reflection of the cascading style sheet text-decoration property.
Specifies the length of indentation appearing before the first formatted line of a block-level HTML text element.
styleObject.textIndent = {length | percentage}
The textIndent property is a reflection of the cascading style sheet text-indent property.
Specifies the case of an HTML text element.
styleObject.textTransform = transformation
The textTransform property is a reflection of the cascading style sheet text-transform property.
Specifies whether or not white space within an HTML element should be collapsed.
styleObject.whiteSpace = {normal | pre}
The whiteSpace property is a reflection of the cascading style sheet white-space property.
Specifies the width of a block-level HTML element.
styleObject.width = {length | percentage | auto}
The width property is a reflection of the cascading style sheet width property.
The Style.marginLeft and Style.marginRight properties take precedence over the Style.width property. For example, if marginLeft is set to 25%, marginRight is set to 10%, and width is set to 100%, Navigator ignores the width value and uses 65% for the width setting.
Table of Contents | Previous
| Next
| Index
Last Updated: 05/28/99 12:00:32
Copyright (c) 1999
Netscape Communications Corporation