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 property explicitly within the block. An instance of this interface might be obtained from the getPropertyCSSValue method of the CSSStyleDeclaration interface. A CSSPrimitiveValue object only occurs in a context of a CSS property.

Conversions are allowed between absolute values (from millimeters to centimeters, from degrees to radians, and so on) but not between relative values. (For example, a pixel value cannot be converted to a centimeter value.) Percentage values can't be converted since they are relative to the parent value (or another property value). There is one exception for color percentage values: since a color percentage value is relative to the range 0-255, a color percentage value can be converted to a number; (see also the RGBColor interface).

An integer indicating which type of unit applies to the value.

The value is not a recognized CSS2 value. The value can only be obtained by using the cssText attribute.

The value is a simple number. The value can be obtained by using the getFloatValue method.

The value is a percentage. The value can be obtained by using the getFloatValue method.

The value is a length (ems). The value can be obtained by using the getFloatValue method.

The value is a length (exs). The value can be obtained by using the getFloatValue method.

The value is a length (px). The value can be obtained by using the getFloatValue method.

The value is a length (cm). The value can be obtained by using the getFloatValue method.

The value is a length (mm). The value can be obtained by using the getFloatValue method.

The value is a length (in). The value can be obtained by using the getFloatValue method.

The value is a length (pt). The value can be obtained by using the getFloatValue method.

The value is a length (pc). The value can be obtained by using the getFloatValue method.

The value is an angle (deg). The value can be obtained by using the getFloatValue method.

The value is an angle (rad). The value can be obtained by using the getFloatValue method.

The value is an angle (grad). The value can be obtained by using the getFloatValue method.

The value is a time (ms). The value can be obtained by using the getFloatValue method.

The value is a time (s). The value can be obtained by using the getFloatValue method.

The value is a frequency (Hz). The value can be obtained by using the getFloatValue method.

The value is a frequency (kHz). The value can be obtained by using the getFloatValue method.

The value is a number with an unknown dimension. The value can be obtained by using the getFloatValue method.

The value is a STRING. The value can be obtained by using the getStringValue method.

The value is a URI. The value can be obtained by using the getStringValue method.

The value is an identifier. The value can be obtained by using the getStringValue method.

The value is a attribute function. The value can be obtained by using the getStringValue method.

The value is a counter or counters function. The value can be obtained by using the getCounterValue method.

The value is a rect function. The value can be obtained by using the getRectValue method.

The value is a RGB color. The value can be obtained by using the getRGBColorValue method.

The type of the value as defined by the constants specified above.

A method to set the float value with a specified unit. If the property attached with this value can not accept the specified unit or the float value, the value will be unchanged and a DOMException will be raised.

A unit code as defined above. The unit code can only be a float unit type (i.e. CSS_NUMBER, CSS_PERCENTAGE, CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM, CSS_IN, CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ, CSS_KHZ, CSS_DIMENSION).

The new float value.

INVALID_ACCESS_ERR: Raised if the attached property doesn't support the float value or the unit type.

NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.

This method is used to get a float value in a specified unit. If this CSS value doesn't contain a float value or can't be converted into the specified unit, a DOMException is raised.

A unit code to get the float value. The unit code can only be a float unit type (i.e. CSS_NUMBER, CSS_PERCENTAGE, CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM, CSS_IN, CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ, CSS_KHZ, CSS_DIMENSION).

The float value in the specified unit.

INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float value or if the float value can't be converted into the specified unit.

A method to set the string value with the specified unit. If the property attached to this value can't accept the specified unit or the string value, the value will be unchanged and a DOMException will be raised.

A string code as defined above. The string code can only be a string unit type (i.e. CSS_STRING, CSS_URI, CSS_IDENT, and CSS_ATTR).

The new string value.

INVALID_ACCESS_ERR: Raised 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.

This method is used to get the string value. If the CSS value doesn't contain a string value, a DOMException is raised.

Some properties (like 'font-family' or 'voice-family') convert a whitespace separated list of idents to a string.

The string value in the current unit. The current primitiveType can only be a string unit type (i.e. CSS_STRING, CSS_URI, CSS_IDENT and CSS_ATTR).

INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value.

This method is used to get the Counter value. If this CSS value doesn't contain a counter value, a DOMException is raised. Modification to the corresponding style property can be achieved using the Counter interface.

The Counter value.

INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Counter value (e.g. this is not CSS_COUNTER).

This method is used to get the Rect value. If this CSS value doesn't contain a rect value, a DOMException is raised. Modification to the corresponding style property can be achieved using the Rect interface.

The Rect value.

INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect value. (e.g. this is not CSS_RECT).

This method is used to get the RGB color. If this CSS value doesn't contain a RGB color value, a DOMException is raised. Modification to the corresponding style property can be achieved using the RGBColor interface.

the RGB color value.

INVALID_ACCESS_ERR: Raised if the attached property can't return a RGB color value (e.g. this is not CSS_RGBCOLOR).