The DOM Level 2 Cascading Style Sheets (CSS) interfaces are designed with the goal of exposing CSS constructs to object model consumers. Cascading Style Sheets is a declarative syntax for defining presentation rules, properties and ancillary constructs used to format and render Web documents. This document specifies a mechanism to programmatically access and modify the rich style and presentation control provided by CSS (specifically CSS level two). This augments CSS by providing a mechanism to dynamically control the inclusion and exclusion of individual style sheets, as well as manipulate CSS rules and properties.
The CSS interfaces are organized in a logical, rather than physical structure. A collection of all style sheets referenced by or embedded in the document is accessible on the document interface. Each item in this collection exposes the properties common to all style sheets referenced or embedded in HTML and XML documents; this interface is described in the Style Sheets chapter of the DOM Level 2. User style sheets are not accessible through this collection, in part due to potential privacy concerns (and certainly read-write issues).
For each CSS style sheet, an additional interface is exposed - the CSSStyleSheet interface. This interface allows access to the collection of rules within a CSS style sheet and methods to modify that collection. Interfaces are provided for each specific type of rule in CSS2 (e.g. style declarations, @import rules, or @font-face rules), as well as a shared generic CSSRule interface.
The most common type of rule is a style declaration. The CSSStyleRule interface that represents this type of rule provides string access to the CSS selector of the rule, and access to the property declarations through the CSSStyleDeclaration interface.
Finally, an optional CSS2Properties interface is described;
this interface (if implemented) provides shortcuts to the string
values of all the properties in CSS level 2.
The interfaces within this section are considered fundamental, and must be implemented by all conforming applications of this specifcation. These interfaces represent CSS style sheets specifically.
A DOM consumer can use the hasFeature of the DOMImplementation interface to determine whether the CSS module has been implemented by a DOM implementation. The feature string for the fundamental interfaces listed in this section is "CSS".
The CSSStyleSheet interface is a concrete interface used
to represent a CSS style sheet i.e. a style sheet whose content type
is "text/css".
interface CSSStyleSheet : StyleSheet {
readonly attribute CSSRule ownerRule;
readonly attribute CSSRuleList cssRules;
unsigned long insertRule(in DOMString rule,
in unsigned long index)
raises(DOMException);
void deleteRule(in unsigned long index)
raises(DOMException);
};
ownerRule@import rule, the
ownerRule attribute will contain the
CSSImportRule. In that case, the ownerNode
attribute in the StyleSheet interface will be
null. If the style sheet comes from an element or a
processing instruction, the ownerRule attribute will be
null and the ownerNode attribute will contain
the Node.
cssRulesinsertRulerule |
The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content. | |
index |
The index within the style sheet's rule list of the rule before which to insert the specified rule. If the specified index is equal to the length of the style sheet's rule collection, the rule will be added to the end of the style sheet. |
DOMExceptionHIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted
at the specified index e.g. if an @import rule
is inserted after a standard rule set or other at-rule.
INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point.
SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.
deleteRuleindex |
The index within the style sheet's rule list of the rule to remove. |
DOMExceptionINDEX_SIZE_ERR: Raised if the specified index does not correspond to a rule in the style sheet's rule list.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.
The CSSRuleList interface provides the
abstraction of an ordered collection of CSS rules.
interface CSSRuleList {
readonly attribute unsigned long length;
CSSRule item(in unsigned long index);
};
lengthCSSRules in the list. The range of valid
child rule indices is 0 to length-1 inclusive.
itemindex |
Index into the collection |
index position in the
CSSRuleList, or null if
that is not a valid index.
The CSSRule interface is the abstract base interface
for any type of CSS statement.
This includes both rule sets and
at-rules. An implementation is expected to preserve all rules specified in
a CSS style sheet, even if it is not recognized. Unrecognized rules
are represented using the CSSUnknownRule interface.
interface CSSRule {
// RuleType
const unsigned short UNKNOWN_RULE = 0;
const unsigned short STYLE_RULE = 1;
const unsigned short CHARSET_RULE = 2;
const unsigned short IMPORT_RULE = 3;
const unsigned short MEDIA_RULE = 4;
const unsigned short FONT_FACE_RULE = 5;
const unsigned short PAGE_RULE = 6;
readonly attribute unsigned short type;
attribute DOMString cssText;
// raises(DOMException) on setting
readonly attribute CSSStyleSheet parentStyleSheet;
readonly attribute CSSRule parentRule;
};
An integer indicating which type of rule this is.
| UNKNOWN_RULE |
The rule is a |
| STYLE_RULE |
The rule is a |
| CHARSET_RULE |
The rule is a |
| IMPORT_RULE |
The rule is a |
| MEDIA_RULE |
The rule is a |
| FONT_FACE_RULE |
The rule is a |
| PAGE_RULE |
The rule is a |
typeCSSRule interface to the specific
derived interface implied by the type.
cssTextDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at this point in the style sheet.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.
parentStyleSheetparentRulenull.
The CSSStyleRule interface represents a single rule set in a CSS style sheet.
interface CSSStyleRule : CSSRule {
attribute DOMString selectorText;
// raises(DOMException) on setting
readonly attribute CSSStyleDeclaration style;
};
selectorTextDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.
style
The CSSMediaRule interface represents a @media
rule in a CSS style sheet. A @media rule can be
used to delimit style rules for specific media types.
interface CSSMediaRule : CSSRule {
readonly attribute MediaList media;
readonly attribute CSSRuleList cssRules;
unsigned long insertRule(in DOMString rule,
in unsigned long index)
raises(DOMException);
void deleteRule(in unsigned long index)
raises(DOMException);
};
mediacssRulesinsertRulerule |
The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content. | |
index |
The index within the media block's rule collection of the rule before which to insert the specified rule. If the specified index is equal to the length of the media blocks's rule collection, the rule will be added to the end of the media block. |
DOMExceptionHIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted
at the specified index. e.g. if an @import rule
is inserted after a standard rule set or other at-rule.
INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point.
SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is readonly.
deleteRuleindex |
The index within the media block's rule collection of the rule to remove. |
DOMExceptionINDEX_SIZE_ERR: Raised if the specified index does not correspond to a rule in the media rule list.
NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is readonly.
The CSSFontFaceRule interface represents a @font-face
rule in a CSS style sheet. The @font-face rule
is used to hold a set of font descriptions.
interface CSSFontFaceRule : CSSRule {
readonly attribute CSSStyleDeclaration style;
};
style
The CSSPageRule interface represents a @page
rule within a CSS style sheet. The @page rule is
used to specify the dimensions, orientation, margins, etc. of a page box
for paged media.
interface CSSPageRule : CSSRule {
attribute DOMString selectorText;
// raises(DOMException) on setting
readonly attribute CSSStyleDeclaration style;
};
selectorTextDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.
style
The CSSImportRule interface represents a @import
rule within a CSS style sheet. The @import rule is
used to import style rules from other style sheets.
interface CSSImportRule : CSSRule {
readonly attribute DOMString href;
readonly attribute MediaList media;
readonly attribute CSSStyleSheet styleSheet;
};
href"url(...)" specifier around the URI.
mediastyleSheet
The CSSCharsetRule interface a @charset
rule in a CSS style sheet. A @charset rule can be
used to define the encoding of the style sheet.
interface CSSCharsetRule : CSSRule {
attribute DOMString encoding;
// raises(DOMException) on setting
};
encoding@charset rule.
DOMExceptionSYNTAX_ERR: Raised if the specified encoding value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this encoding rule is readonly.
The CSSUnkownRule interface represents an at-rule not
supported by this user agent.
interface CSSUnknownRule : CSSRule {
};
The CSSStyleDeclaration interface represents a single
CSS declaration block. This interface may be used to determine the style properties
currently set in a block or to set style properties explicitly within
the block.
While an implementation may not recognize all CSS properties within
a CSS declaration block, it is expected to provide access to all specified
properties through the CSSStyleDeclaration interface.
Furthermore, implementations that support a specific level of CSS
should correctly handle CSS shorthand properties for that level. For a further
discussion of shorthand properties, see the CSS2Properties
interface.
interface CSSStyleDeclaration {
attribute DOMString cssText;
// raises(DOMException) on setting
DOMString getPropertyValue(in DOMString propertyName);
CSSValue getPropertyCSSValue(in DOMString propertyName);
DOMString removeProperty(in DOMString propertyName)
raises(DOMException);
DOMString getPropertyPriority(in DOMString propertyName);
void setProperty(in DOMString propertyName,
in DOMString value,
in DOMString priority)
raises(DOMException);
readonly attribute unsigned long length;
DOMString item(in unsigned long index);
readonly attribute CSSRule parentRule;
};
cssTextDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
lengthparentRulegetPropertyValuepropertyName |
The name of the CSS property. See the CSS property index. |
getPropertyCSSValuegetPropertyValue and setProperty methods.
propertyName |
The name of the CSS property. See the CSS property index. |
null if the property
has not been set.
removePropertypropertyName |
The name of the CSS property. See the CSS property index. |
DOMExceptionNO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
getPropertyPriority"important" qualifier) if the property
has been explicitly set in this declaration block.
propertyName |
The name of the CSS property. See the CSS property index. |
"important")
if one exists. The empty string if none exists.
setPropertypropertyName |
The name of the CSS property. See the CSS property index. | |
value |
The new value of the property. | |
priority |
The new priority of the property (e.g. |
DOMExceptionSYNTAX_ERR: Raised if the specified value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
itemindex |
Index of the property name to retrieve. |
The CSSValue interface represents a simple or a complexe
value.
interface CSSValue {
// UnitTypes
const unsigned short CSS_PRIMITIVE_VALUE = 0;
const unsigned short CSS_VALUE_LIST = 1;
const unsigned short CSS_CUSTOM = 2;
attribute DOMString cssText;
// raises(DOMException) on setting
readonly attribute unsigned short valueType;
};
An integer indicating which type of unit applies to the value. Note: All CSS2 constants are not supposed to be required by the
implementation since all CSS2 interfaces are optionals.
| CSS_PRIMITIVE_VALUE |
The value is a |
| CSS_VALUE_LIST |
The value is a list |
| CSS_CUSTOM |
The value is a custom value. |
cssTextDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
valueType
The CSSPrimitiveValue interface represents a single CSS
value. This interface may be used to determine the value of a specific
style property currently set in a block or to set a specific style properties
explicitly within the block. An instance of this interface can be
obtained from the getPropertyCSSValue method of the
CSSStyleDeclaration interface.
interface CSSPrimitiveValue : CSSValue {
// UnitTypes
const unsigned short CSS_UNKNOWN = 0;
const unsigned short CSS_INHERIT = 1;
const unsigned short CSS_NUMBER = 2;
const unsigned short CSS_PERCENTAGE = 3;
const unsigned short CSS_EMS = 4;
const unsigned short CSS_EXS = 5;
const unsigned short CSS_PX = 6;
const unsigned short CSS_CM = 7;
const unsigned short CSS_MM = 8;
const unsigned short CSS_IN = 9;
const unsigned short CSS_PT = 10;
const unsigned short CSS_PC = 11;
const unsigned short CSS_DEG = 12;
const unsigned short CSS_RAD = 13;
const unsigned short CSS_GRAD = 14;
const unsigned short CSS_MS = 15;
const unsigned short CSS_S = 16;
const unsigned short CSS_HZ = 17;
const unsigned short CSS_KHZ = 18;
const unsigned short CSS_DIMENSION = 19;
const unsigned short CSS_STRING = 20;
const unsigned short CSS_URI = 21;
const unsigned short CSS_IDENT = 22;
const unsigned short CSS_ATTR = 23;
const unsigned short CSS_COUNTER = 24;
const unsigned short CSS_RECT = 26;
const unsigned short CSS_RGBCOLOR = 27;
readonly attribute unsigned short primitiveType;
void setFloatValue(in unsigned short unitType,
in float floatValue)
raises(DOMException);
float getFloatValue(in unsigned short unitType)
raises(DOMException);
void setStringValue(in unsigned short stringType,
in DOMString stringValue)
raises(DOMException);
DOMString getStringValue()
raises(DOMException);
Counter getCounterValue()
raises(DOMException);
Rect getRectValue()
raises(DOMException);
RGBColor getRGBColorValue()
raises(DOMException);
};
An integer indicating which type of unit applies to the value.
| CSS_UNKNOWN |
The value is not a recognized CSS2 value. The value can only be
obtained by using the |
| CSS_INHERIT |
The value is the |
| CSS_NUMBER |
The value is a simple number.
The value can be obtained by using the |
| CSS_PERCENTAGE |
The value is a percentage.
The value can be obtained by using the |
| CSS_EMS |
The value is length
(ems). The value can be obtained by using the |
| CSS_EXS |
The value is length
(exs). The value can be obtained by using the |
| CSS_PX |
The value is length
(px). The value can be obtained by using the |
| CSS_CM |
The value is length
(cm). The value can be obtained by using the |
| CSS_MM |
The value is length
(mm). The value can be obtained by using the |
| CSS_IN |
The value is length
(in). The value can be obtained by using the |
| CSS_PT |
The value is length
(pt). The value can be obtained by using the |
| CSS_PC |
The value is a length
(pc). The value can be obtained by using the |
| CSS_DEG |
The value is an angle
(deg). The value can be obtained by using the |
| CSS_RAD |
The value is an angle
(rad). The value can be obtained by using the |
| CSS_GRAD |
The value is an angle
(grad). The value can be obtained by using the |
| CSS_MS |
The value is a time
(ms). The value can be obtained by using the |
| CSS_S |
The value is a time (s).
The value can be obtained by using the |
| CSS_HZ |
The value is a frequency
(Hz). The value can be obtained by using the |
| CSS_KHZ |
The value is a frequency
(kHz). The value can be obtained by using the |
| CSS_DIMENSION |
The value is a number with an unknown dimension.
The value can be obtained by using the |
| CSS_STRING |
The value is a STRING.
The value can be obtained by using the |
| CSS_URI |
The value is a URI.
The value can be obtained by using the |
| CSS_IDENT |
The value is an identifier.
The value can be obtained by using the |
| CSS_ATTR |
The value is a attribute
function. The value can be obtained by using the |
| CSS_COUNTER |
The value is a counter or
counters function. The value can be obtained by using the
|
| CSS_RECT |
The value is a rect
function. The value can be obtained by using the |
| CSS_RGBCOLOR |
The value is a RGB
color. The value can be obtained by using the |
primitiveTypesetFloatValueDOMException will
be raised.
unitType |
A unit code as defined above. The unit code can only be a float
unit type (e.g. | |
floatValue |
The new float value. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the attached property doesn't support the float value or the unit type.
NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
getFloatValueDOMException is raised.
unitType |
A unit code to get the float value. The unit code can only be a float
unit type (e.g. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a float value or if the float value can't be converted into the specified unit.
setStringValueDOMException will
be raised.
stringType |
A string code as defined above. The string code can only be a
string unit type (e.g. | |
stringValue |
The new string value. If the |
DOMExceptionINVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a string value or if the string value can't be converted into the specified unit.
NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
getStringValueDOMException
is raised.
valueType can only be a string unit type
(e.g. CSS_URI, CSS_IDENT and
CSS_ATTR).
DOMExceptionINVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a string value.
getCounterValueDOMException is
raised. Modification to the corresponding style property can be
achieved using the Counter interface.
DOMExceptionINVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a Counter value.
getRectValueDOMException is
raised. Modification to the corresponding style property can be
achieved using the Rect interface.
DOMExceptionINVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a Rect value.
getRGBColorValueDOMException is
raised. Modification to the corresponding style property can be
achieved using the RGBColor interface.
DOMExceptionINVALID_ACCESS_ERR: Raises if the attached property can't return a RGB color value.
The CSSValueList interface provides the absraction of an
ordered collection of CSS values.
interface CSSValueList : CSSValue {
readonly attribute unsigned long length;
CSSValue item(in unsigned long index);
};
lengthCSSValues in the list. The range of valid
values indices is 0 to length-1 inclusive.itemindex |
Index into the collection. |
index position in the
CSSValueList, or null if that is not valid
index.
The RGBColor interface is used to represent any RGB color
value. This interface reflects the values in the underlying style
property. Hence, modifications made through this interface modify
the style property.
interface RGBColor {
attribute CSSValue red;
attribute CSSValue green;
attribute CSSValue blue;
};
redgreenblue
The Rect interface is used to represent any
rect value. This interface reflects the values in the underlying style
property. Hence, modifications made through this interface modify
the style property.
interface Rect {
attribute CSSValue top;
attribute CSSValue right;
attribute CSSValue bottom;
attribute CSSValue left;
};
toprightbottomleft
The Counter interface is used to represent any counter or
counters function value. This interface reflects the values in
the underlying style property. Hence, modifications made through this
interface modify the style property.
interface Counter {
attribute DOMString identifier;
attribute DOMString listStyle;
attribute DOMString separator;
};
identifierlistStyleseparator
The interfaces found within this section are not mandatory. A DOM
consumer can use the hasFeature of the
DOMImplementation interface to determine whether
the CSS2 extended interfaces have been implemented by a DOM implementation.
The feature string for all the extended interfaces listed in this
section except the CSS2Properties interface is "CSS2".
The following table specifies the type of CSSValue used
to represent each property that can be specified in a
CSSStyleDeclaration found in a CSSStyleRule for
a CSS Level 2 style sheet. The expectation is that the
CSSValue returned from the getPropertyCSSValue
method on the CSSStyleDeclaration interface can be
cast down, using binding-specific casting methods, to the specific
derived interface.
For properties that are represented by a custom interface (the
valueType of the CSSValue is
CSS_CUSTOM), the name of the derived interface is specified in
the table.
For properties that consist of lists of values (the valueType
of the CSSValue is CSS_VALUE_LIST), the
derived interface is CSSValueList. For all other
properties (the valueType
of the CSSValue is CSS_PRIMITIVE_VALUE), the
derived interface is CSSPrimitiveValue.
| Property Name | Representation |
| azimuth | CSS2Azimuth |
| background | null |
| background-attachment | ident |
| background-color | rgbcolor, ident |
| background-image | uri, ident |
| background-position | CSS2BackgroundPosition |
| background-repeat | ident |
| border | null |
| border-collapse | ident |
| border-color | null |
| border-spacing | CSS2BorderSpacing |
| border-style | null |
| border-top, border-right, border-bottom, border-left | null |
| border-top-color, border-right-color, border-bottom-color, border-left-color | rgbcolor, ident |
| border-top-style, border-right-style, border-bottom-style, border-left-style | ident |
| border-top-width, border-right-width, border-bottom-width, border-left-width | length, ident |
| border-width | null |
| bottom | length, percentage, ident |
| caption-side | ident |
| clear | ident |
| clip | rect, ident |
| color | rgbcolor, ident |
| content | list of string, uri, counter, attr, ident |
| counter-increment | list of CSS2CounterIncrement |
| counter-reset | list of CSS2CounterReset |
| cue | null |
| cue-after, cue-before | uri, ident |
| cursor | CSS2Cursor |
| direction | ident |
| display | ident |
| elevation | angle, ident |
| empty-cells | ident |
| float | ident |
| font | null |
| font-family | list of strings and idents |
| font-size | ident, length, percentage |
| font-size-adjust | number, ident |
| font-stretch | ident |
| font-style | ident |
| font-variant | ident |
| font-weight | ident |
| height | length, percentage, ident |
| left | length, percentage, ident |
| letter-spacing | ident, length |
| line-height | ident, length, percentage, number |
| list-style | null |
| list-style-image | uri, ident |
| list-style-position | ident |
| list-style-type | ident |
| margin | null |
| margin-top, margin-right, margin-bottom, margin-left | length, percentage, ident |
| marker-offset | length, ident |
| max-height | length, percentage, ident |
| max-width | length, percentage, ident |
| min-height | length, percentage, ident |
| min-width | length, percentage, ident |
| orphans | number |
| outline | null |
| outline-color | rgbcolor, ident |
| outline-style | ident |
| outline-width | length, ident |
| overflow | ident |
| padding | null |
| padding-top, padding-right, padding-bottom, padding-left | length, percentage |
| page | ident |
| page-break-after | ident |
| page-break-before | ident |
| page-break-inside | ident |
| pause | null |
| pause-after, pause-before | time, percentage |
| pitch | frequency, identifier |
| pitch-range | number |
| play-during | CSS2PlayDuring |
| position | ident |
| quotes | list of string or ident |
| richness | number |
| right | length, percentage, ident |
| speak | ident |
| speak-header | ident |
| speak-numeral | ident |
| speak-punctuation | ident |
| speech-rate | number, ident |
| stress | number |
| table-layout | ident |
| text-align | ident, string |
| text-decoration | list of ident |
| text-indent | length, percentage |
| text-shadow | list of CSS2TextShadow |
| text-transform | ident |
| top | length, percentage, ident |
| unicode-bidi | ident |
| vertical-align | ident, percentage, length |
| visibility | ident |
| voice-family | list of strings and idents |
| volume | number, percentage, ident |
| white-space | ident |
| widows | number |
| width | length, percentage, ident |
| word-spacing | length, ident |
| z-index | ident, number |
The CSS2Azimuth interface represents the azimuth
CSS Level 2 property.
interface CSS2Azimuth : CSSValue {
readonly attribute unsigned short azimuthType;
readonly attribute DOMString identifier;
readonly attribute boolean behind;
void setAngleValue(in unsigned short unitType,
in float floatValue)
raises(DOMException);
float getAngleValue(in unsigned short unitType)
raises(DOMException);
void setIdentifier(in DOMString identifier,
in boolean behind)
raises(DOMException);
};
azimuthTypeCSSValue. It would be one of CSS_DEG,
CSS_RAD, CSS_GRAD or
CSS_IDENT.identifierazimuthType is CSS_IDENT,
identifier contains one of left-side, far-left, left,
center-left, center, center-right, right, far-right, right-side,
leftwards, rightwards. The empty string if none is set.behindbehind indicates whether the behind identifier has been
set.setAngleValueunitType |
The unitType could only be one of | |
floatValue |
The new float value of the angle. |
DOMExceptionINVALID_ACCESS_ERR: Raised if the unit type is invalid.
NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
getAngleValueunitType |
The unit type can be only an angle unit type
( |
DOMExceptionINVALID_ACCESS_ERR: Raised if the unit type is invalid.
setIdentifierazimuthType is set
to CSS_IDENT
identifier |
The new identifier. If the identifier is "leftwards" or "rightward", the behind attribute is ignored. | |
behind |
The new value for behind. |
DOMExceptionSYNTAX_ERR: Raised if the specified identifier has a
syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
The CSS2BackgroundPosition interface represents the background-position
CSS Level 2 property.
interface CSS2BackgroundPosition : CSSValue {
readonly attribute unsigned short horizontalType;
readonly attribute unsigned short verticalType;
readonly attribute DOMString horizontalIdentifier;
readonly attribute DOMString verticalIdentifier;
float getHorizontalPosition(in float horizontalType)
raises(DOMException);
float getVerticalPosition(in float verticalType)
raises(DOMException);
void setHorizontalPosition(in unsigned short horizontalType,
in float value)
raises(DOMException);
void setVerticalPosition(in unsigned short verticalType,
in float value)
raises(DOMException);
void setPositionIdentifier(in DOMString horizontalIdentifier,
in DOMString verticalIdentifier)
raises(DOMException);
};
horizontalTypeCSS_PERCENTAGE, CSS_EMS,
CSS_EXS, CSS_PX, CSS_CM,
CSS_MM, CSS_IN, CSS_PT,
CSS_PC, CSS_IDENT,
CSS_INHERIT. If one of horizontal or vertical is
CSS_IDENT or CSS_INHERIT, it's guaranteed
that the other is the same.
verticalTypeCSS_PERCENTAGE,
CSS_EMS, CSS_EXS, CSS_PX,
CSS_CM, CSS_MM, CSS_IN,
CSS_PT, CSS_PC, CSS_IDENT,
CSS_INHERIT. If one of horizontal or vertical is
CSS_IDENT or CSS_INHERIT, it's guaranteed
that the other is the same.
horizontalIdentifierhorizontalType is CSS_IDENT or
CSS_INHERIT, this attribute contains the string
representation of the ident, otherwise it contains an empty string.
verticalIdentifierverticalType is CSS_IDENT or
CSS_INHERIT, this attribute contains the string
representation of the ident, otherwise it contains an empty string. The
value is "center" if only the horizontalIdentifier has
been set. The value is "inherit" if the
horizontalIdentifier is "inherit".
getHorizontalPositionhorizontalPosition represents a length or a percentage. If
the float doesn't contain a float value or can't be converted into the
specified unit, a DOMException is raised.
horizontalType |
The specified unit. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the property doesn't contain a float or the value can't be converted.
getVerticalPositionverticalPosition represents a length or a percentage. If the
float doesn't contain a float value or can't be converted into the
specified unit, a DOMException is raised. The value is
50% if only the horizontal value has been specified.
verticalType |
The specified unit. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the property doesn't contain a float or the value can't be converted.
setHorizontalPosition50%.
horizontalType |
The specified unit (a length or a percentage). | |
value |
The new value. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the specified unit is not a length or a percentage.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
setVerticalPosition50%.
verticalType |
The specified unit (a length or a percentage). | |
value |
The new value. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the specified unit is not a length or a percentage.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
setPositionIdentifier"center"). If the first identfier is "inherit,
the second identifier is ignored and is set to
"inherit".
horizontalIdentifier |
The new horizontal identifier. | |
verticalIdentifier |
The new vertical identifier. |
DOMExceptionSYNTAX_ERR: Raises if the identifiers have a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
The CSS2BorderSpacing interface represents the border-spacing
CSS Level 2 property.
interface CSS2BorderSpacing : CSSValue {
readonly attribute unsigned short horizontalType;
readonly attribute unsigned short verticalType;
float getHorizontalSpacing(in float horizontalType)
raises(DOMException);
float getVerticalSpacing(in float verticalType)
raises(DOMException);
void setHorizontalSpacing(in unsigned short horizontalType,
in float value)
raises(DOMException);
void setVerticalSpacing(in unsigned short verticalType,
in float value)
raises(DOMException);
void setInherit()();
};
horizontalTypeCSSValue. It would be one of CSS_EMS,
CSS_EXS, CSS_PX, CSS_CM,
CSS_MM, CSS_IN, CSS_PT,
CSS_PC or CSS_INHERIT.
verticalTypeCSSValue. It would be one of CSS_EMS,
CSS_EXS, CSS_PX, CSS_CM,
CSS_MM, CSS_IN, CSS_PT,
CSS_PC or CSS_INHERIT.
getHorizontalSpacinghorizontalSpacing represents a length. If the float doesn't
contain a float value or can't be converted into the specified unit, a
DOMException is raised.
horizontalType |
The specified unit. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the property doesn't contain a float or the value can't be converted.
getVerticalSpacingverticalSpacing represents a length. If the float doesn't
contain a float value or can't be converted into the specified unit, a
DOMException is raised. The value is 0 if only
the horizontal value has been specified.
verticalType |
The specified unit. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the property doesn't contain a float or the value can't be converted.
setHorizontalSpacing0.
horizontalType |
The specified unit. | |
value |
The new value. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the specified unit is not a length.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
setVerticalSpacing0.
verticalType |
The specified unit. | |
value |
The new value. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the specified unit is not a length or a percentage.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
setInherit()horizontalType and
verticalType will be inherited.The CSS2CounterReset interface represents a simple value
for the counter-reset
CSS Level 2 property.
interface CSS2CounterReset {
attribute DOMString identifier;
// raises(DOMException) on setting
attribute short reset;
// raises(DOMException) on setting
};
identifierDOMExceptionSYNTAX_ERR: Raised if the specified identifier has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly.
resetDOMExceptionNO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly.
The CSS2CounterIncrement interface represents a imple value
for the counter-increment
CSS Level 2 property.
interface CSS2CounterIncrement {
attribute DOMString identifier;
// raises(DOMException) on setting
attribute short increment;
// raises(DOMException) on setting
};
identifierDOMExceptionSYNTAX_ERR: Raised if the specified identifier has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly.
incrementDOMExceptionNO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is readonly.
The CSS2Cursor interface represents the cursor
CSS Level 2 property.
interface CSS2Cursor : CSSValue {
attribute unsigned short cursorType;
readonly attribute CSSValueList uris;
attribute DOMString predefinedCursor;
// raises(DOMException) on setting
};
cursorTypeCSS_UNKNOWN or CSS_INHERIT. If the type is
CSS_UNKNOWN, then uris contains a list of
URIs and predefinedCursor contains an ident. Setting this
attribute from CSS_INHERIT to CSS_UNKNOWN
will set the predefinedCursor to "auto".urisuris represents the list of URIs (CSS_URI)
on the cursor property. The list can be empty.predefinedCursorDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
The CSS2PlayDuring interface represents the play-during
CSS Level 2 property.
interface CSS2PlayDuring : CSSValue {
readonly attribute unsigned short playDuringType;
attribute DOMString playDuringIdentifier;
// raises(DOMException) on setting
attribute DOMString uri;
// raises(DOMException) on setting
attribute boolean mix;
// raises(DOMException) on setting
attribute boolean repeat;
// raises(DOMException) on setting
};
playDuringTypeCSSvalue. It would be one of CSS_UNKNOWN,
CSS_INHERIT, CSS_IDENT.playDuringIdentifier"inherit", "auto",
"none" or the empty string if the
playDuringType is CSS_UNKNOWN. On setting, it
will set the uri to the empty string and mix
and repeat to false.
DOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
uriuri. It will set the
playDuringType attribute to CSS_UNKNOWN.
DOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
mixtrue if the sound should be mixed. It will be ignored if
the attribute doesn't contain a uri.
DOMExceptionNO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
repeattrue if the sound should be repeated. It will be ignored
if the attribute doesn't contain a uri.
DOMExceptionNO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
The CSS2TextShadow interface represents a simple value for
the text-shadow
CSS Level 2 property.
interface CSS2TextShadow {
readonly attribute CSSValue color;
readonly attribute CSSValue horizontal;
readonly attribute CSSValue vertical;
readonly attribute CSSValue blur;
};
colorhorizontal0 if no
length has been specified.vertical0 if no
length has been specified.blur0 if no
length has been specified.The following table specifies the type of CSSValue used
to represent each property that can be specified in a
CSSStyleDeclaration found in a CSSFontFaceRule
for a CSS Level 2 style sheet.
| Property Name | Representation |
| font-family | list of strings and idents |
| font-style | list of idents |
| font-variant | list of idents |
| font-weight | list of idents |
| font-stretch | list of idents |
| font-size | list of lengths or ident |
| unicode-range | list of strings |
| units-per-em | number |
| src | list of CSS2FontFaceSrc |
| panose-1 | list of integers |
| stemv | number |
| stemh | number |
| slope | number |
| cap-height | number |
| x-height | number |
| ascent | number |
| descent | number |
| widths | list of CSS2FontFaceWidths |
| bbox | list of numbers |
| definition-src | uri |
| baseline | number |
| centerline | number |
| mathline | number |
| topline | number |
The CSS2Cursor interface represents the src
CSS Level 2 descriptor.
interface CSS2FontFaceSrc {
attribute DOMString uri;
// raises(DOMException) on setting
readonly attribute CSSValueList format;
attribute DOMString fontFaceName;
// raises(DOMException) on setting
};
uriDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
formatfontFaceNameDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
The CSS2Cursor interface represents a simple value for the
widths
CSS Level 2 descriptor.
interface CSS2FontFaceWidths {
attribute DOMString urange;
// raises(DOMException) on setting
readonly attribute CSSValueList numbers;
};
urangeDOMExceptionSYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly.
numbersThe following table specifies the type of CSSValue used
to represent each property that can be specified in a
CSSStyleDeclaration found in a CSSPageRule
for a CSS Level 2 style sheet.
| Property Name | Representation |
| margin | null |
| margin-top, margin,right, margin-bottom, margin-left | length (no CSS_EMS and CSS_EXS), percentage, ident |
| marks | list of idents |
| size | CSS2PageSize |
The CSS2Cursor interface represents the size
CSS Level 2 descriptor.
interface CSS2PageSize : CSSValue {
readonly attribute unsigned short widthType;
readonly attribute unsigned short heightType;
readonly attribute DOMString identifier;
float getWidth(in float widthType)
raises(DOMException);
float getHeightSize(in float heightType)
raises(DOMException);
void setWidthSize(in unsigned short widthType,
in float value)
raises(DOMException);
void setHeightSize(in unsigned short heightType,
in float value)
raises(DOMException);
void setIdentifier(in DOMString identifier)
raises(DOMException);
};
widthTypeCSS_EMS, CSS_EXS, CSS_PX,
CSS_CM, CSS_MM, CSS_IN,
CSS_PT, CSS_PC, CSS_IDENT,
CSS_INHERIT. If one of width or height is
CSS_IDENT or CSS_INHERIT, it's guaranteed that
the other is the same.heightTypeCSS_EMS, CSS_EXS, CSS_PX,
CSS_CM, CSS_MM, CSS_IN,
CSS_PT, CSS_PC, CSS_IDENT,
CSS_INHERIT. If one of width or height is
CSS_IDENT or CSS_INHERIT, it's guaranteed that
the other is the same.identifierwidth is CSS_IDENT or
CSS_INHERIT, this attribute contains the string
representation of the ident, otherwise it contains an empty string.
getWidthwidthType represents a length. If the float doesn't contain a
float value or can't be converted into the specified unit, a
DOMException is raised.
widthType |
The specified unit. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the property doesn't contain a float or the value can't be converted.
getHeightSizeheightType represents a length. If the float doesn't contain
a float value or can't be converted into the specified unit, a
DOMException is raised. If only the width value has been
specified, the height value is the same.
heightType |
The specified unit. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the property doesn't contain a float or the value can't be converted.
setWidthSizeheightType is not a length, it sets
the height position to the same value.
widthType |
The specified unit. | |
value |
The new value. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the specified unit is not a length or a percentage.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
setHeightSizewidthType is not a length, it sets
the width position to the same value.
heightType |
The specified unit. | |
value |
The new value. |
DOMExceptionINVALID_ACCESS_ERR: Raises if the specified unit is not a length or a percentage.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
setIdentifieridentifier |
The new identifier. |
DOMExceptionSYNTAX_ERR: Raises if the identifier has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raises if this property is readonly.
The following interface may be implemented by a DOM implementation as a
convenience to the DOM script user. A DOM
consumer can use the hasFeature of the
DOMImplementation interface to determine whether
the CSS2Properties interface has been implemented by the
DOM implementation. The festure string for the CSS2Properties
interface is "CSS2Properties".
The CSS2Properties interface represents a convenience
mechanism for retrieving and setting properties within a
CSSStyleDeclaration. The attributes of this interface
correspond to all the properties specified in CSS2. Getting an attribute of this
interface is equivalent
to calling the getPropertyValue method of the
CSSStyleDeclaration interface. Setting an attribute of this
interface
is equivalent to calling the setProperty method of
the CSSStyleDeclaration interface.
A compliant implementation is not required to implement the
CSS2Properties interface. If an implementation does
implement this interface, the expectation is that language-specific
methods can be used to cast from an instance of the
CSSStyleDeclaration interface to the
CSS2Properties interface.
If an implementation
does implement this interface, it is expected to understand
the specific syntax of the shorthand properties, and apply their
semantics; when the margin property is set, for
example, the marginTop, marginRight,
marginBottom and marginLeft properties
are actually being set by the underlying implementation.
When dealing with CSS "shorthand" properties, the shorthand properties should be decomposed into their component longhand properties as appropriate, and when querying for their value, the form returned should be the shortest form exactly equivalent to the declarations made in the ruleset. However, if there is no shorthand declaration that could be added to the ruleset without changing in any way the rules already declared in the ruleset (i.e., by adding longhand rules that were previously not declared in the ruleset), then the empty string should be returned for the shorthand property.
For example, querying for the font property
should not return
"normal normal normal 14pt/normal Arial, sans-serif", when
"14pt Arial, sans-serif" suffices (the normals are initial values,
and are implied by use of the longhand property).
If the values for all the longhand properties that compose a
particular string are the initial values, then a string
consisting of all the initial values should be returned
(e.g. a border-width value of "medium" should
be returned as such, not as "").
For some shorthand properties that take missing values from
other sides, such as the margin,
padding, and
border-[width|style|color] properties, the
minimum number of sides possible should be used, i.e., "0px
10px" will be returned instead of "0px 10px 0px 10px".
If the value of a shorthand property can not be decomposed
into its component longhand properties, as is the case for
the font property with a value of "menu",
querying for the values of the component longhand properties
should return the empty string.
interface CSS2Properties {
attribute DOMString azimuth;
attribute DOMString background;
attribute DOMString backgroundAttachment;
attribute DOMString backgroundColor;
attribute DOMString backgroundImage;
attribute DOMString backgroundPosition;
attribute DOMString backgroundRepeat;
attribute DOMString border;
attribute DOMString borderCollapse;
attribute DOMString borderColor;
attribute DOMString borderSpacing;
attribute DOMString borderStyle;
attribute DOMString borderTop;
attribute DOMString borderRight;
attribute DOMString borderBottom;
attribute DOMString borderLeft;
attribute DOMString borderTopColor;
attribute DOMString borderRightColor;
attribute DOMString borderBottomColor;
attribute DOMString borderLeftColor;
attribute DOMString borderTopStyle;
attribute DOMString borderRightStyle;
attribute DOMString borderBottomStyle;
attribute DOMString borderLeftStyle;
attribute DOMString borderTopWidth;
attribute DOMString borderRightWidth;
attribute DOMString borderBottomWidth;
attribute DOMString borderLeftWidth;
attribute DOMString borderWidth;
attribute DOMString bottom;
attribute DOMString captionSide;
attribute DOMString clear;
attribute DOMString clip;
attribute DOMString color;
attribute DOMString content;
attribute DOMString counterIncrement;
attribute DOMString counterReset;
attribute DOMString cue;
attribute DOMString cueAfter;
attribute DOMString cueBefore;
attribute DOMString cursor;
attribute DOMString direction;
attribute DOMString display;
attribute DOMString elevation;
attribute DOMString emptyCells;
attribute DOMString cssFloat;
attribute DOMString font;
attribute DOMString fontFamily;
attribute DOMString fontSize;
attribute DOMString fontSizeAdjust;
attribute DOMString fontStretch;
attribute DOMString fontStyle;
attribute DOMString fontVariant;
attribute DOMString fontWeight;
attribute DOMString height;
attribute DOMString left;
attribute DOMString letterSpacing;
attribute DOMString lineHeight;
attribute DOMString listStyle;
attribute DOMString listStyleImage;
attribute DOMString listStylePosition;
attribute DOMString listStyleType;
attribute DOMString margin;
attribute DOMString marginTop;
attribute DOMString marginRight;
attribute DOMString marginBottom;
attribute DOMString marginLeft;
attribute DOMString markerOffset;
attribute DOMString marks;
attribute DOMString maxHeight;
attribute DOMString maxWidth;
attribute DOMString minHeight;
attribute DOMString minWidth;
attribute DOMString orphans;
attribute DOMString outline;
attribute DOMString outlineColor;
attribute DOMString outlineStyle;
attribute DOMString outlineWidth;
attribute DOMString overflow;
attribute DOMString padding;
attribute DOMString paddingTop;
attribute DOMString paddingRight;
attribute DOMString paddingBottom;
attribute DOMString paddingLeft;
attribute DOMString page;
attribute DOMString pageBreakAfter;
attribute DOMString pageBreakBefore;
attribute DOMString pageBreakInside;
attribute DOMString pause;
attribute DOMString pauseAfter;
attribute DOMString pauseBefore;
attribute DOMString pitch;
attribute DOMString pitchRange;
attribute DOMString playDuring;
attribute DOMString position;
attribute DOMString quotes;
attribute DOMString richness;
attribute DOMString right;
attribute DOMString size;
attribute DOMString speak;
attribute DOMString speakHeader;
attribute DOMString speakNumeral;
attribute DOMString speakPunctuation;
attribute DOMString speechRate;
attribute DOMString stress;
attribute DOMString tableLayout;
attribute DOMString textAlign;
attribute DOMString textDecoration;
attribute DOMString textIndent;
attribute DOMString textShadow;
attribute DOMString textTransform;
attribute DOMString top;
attribute DOMString unicodeBidi;
attribute DOMString verticalAlign;
attribute DOMString visibility;
attribute DOMString voiceFamily;
attribute DOMString volume;
attribute DOMString whiteSpace;
attribute DOMString widows;
attribute DOMString width;
attribute DOMString wordSpacing;
attribute DOMString zIndex;
};
azimuthbackgroundbackgroundAttachmentbackgroundColorbackgroundImagebackgroundPositionbackgroundRepeatborderborderCollapseborderColorborderSpacingborderStyleborderTopborderRightborderBottomborderLeftborderTopColorborderRightColorborderBottomColorborderLeftColorborderTopStyleborderRightStyleborderBottomStyleborderLeftStyleborderTopWidthborderRightWidthborderBottomWidthborderLeftWidthborderWidthbottomcaptionSideclearclipcolorcontentcounterIncrementcounterResetcuecueAftercueBeforecursordirectiondisplayelevationemptyCellscssFloatfontfontFamilyfontSizefontSizeAdjustfontStretchfontStylefontVariantfontWeightheightleftletterSpacinglineHeightlistStylelistStyleImagelistStylePositionlistStyleTypemarginmarginTopmarginRightmarginBottommarginLeftmarkerOffsetmarksmaxHeightmaxWidthminHeightminWidthorphansoutlineoutlineColoroutlineStyleoutlineWidthoverflowpaddingpaddingToppaddingRightpaddingBottompaddingLeftpagepageBreakAfterpageBreakBeforepageBreakInsidepausepauseAfterpauseBeforepitchpitchRangeplayDuringpositionquotesrichnessrightsizespeakspeakHeaderspeakNumeralspeakPunctuationspeechRatestresstableLayouttextAligntextDecorationtextIndenttextShadowtextTransformtopunicodeBidiverticalAlignvisibilityvoiceFamilyvolumewhiteSpacewidowswidthwordSpacingzIndex
Inline style information attached to HTML elements is exposed
through the style attribute. This represents the
contents of the
STYLE attribute for HTML elements.
interface HTMLElementStyle : HTMLElement {
readonly attribute CSSStyleDeclaration style;
};
The style sheet associated with an HTML STYLE element is accessible via the styleSheet attribute.
interface HTMLStyleElement2 : HTMLStyleElement {
readonly attribute StyleSheet styleSheet;
};
The styleSheet associated with an HTML LINK element with a REL
of "stylesheet" or "alternate stylesheet" is not accessible
directly. This is because LINK elements are not used
purely as a stylesheet
linking mechanism. The styleSheet property on LINK elements
with other relationships would be incongruous.