Help Center

Local Navigation

Object: CSSPrimitiveValue

Availability

BlackBerry® Device Software version 4.6 or later

Extends

CSSValue

The CSSPrimitiveValue object represents a single CSS value. A CSSPrimitiveValue object only occurs in the context of a CSS property.

This object has methods to determine the current value of a specific style property, or to explicitly set a style 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. With the exception of values representing colors, percentage values can not be converted, since they are relative to another value.

Because a color percentage value is relative to a known range (0 to 255), however, a color percentage value can be converted to a number.

CSSPrimitiveValue constants

Constant

Value type

Description

Support level

Availability

0

CSS_UNKNOWN

An unrecognized unit type.

DOM 2 Style

4.6 or later

1

CSS_NUMBER

A simple number value.

DOM 2 Style

4.6 or later

2

CSS_PERCENTAGE

A percentage value.

DOM 2 Style

4.6 or later

3

CSS_EMS

A length value, based on font size.

DOM 2 Style

4.6 or later

4

CSS_EXS

A length value, based on font x-height.

DOM 2 Style

4.6 or later

5

CSS_PX

A length value, in pixels.

DOM 2 Style

4.6 or later

6

CSS_CM

A length value, in centimeters.

DOM 2 Style

4.6 or later

7

CSS_MM

A length value, in millimeters.

DOM 2 Style

4.6 or later

8

CSS_IN

A length value, in inches.

DOM 2 Style

4.6 or later

9

CSS_PT

A length value, in points.

DOM 2 Style

4.6 or later

10

CSS_PC

A length value, in picas.

DOM 2 Style

4.6 or later

11

CSS_DEG

An angle value, in degrees.

DOM 2 Style

4.6 or later

12

CSS_RAD

An angle value, in radians.

DOM 2 Style

4.6 or later

13

CSS_GRAD

An angle value, in grads.

DOM 2 Style

4.6 or later

14

CSS_MS

A time value, in milliseconds.

DOM 2 Style

4.6 or later

15

CSS_S

A time value, in seconds.

DOM 2 Style

4.6 or later

16

CSS_HZ

A frequency value, in Hertz.

DOM 2 Style

4.6 or later

17

CSS_KHZ

A frequency, in kiloHertz.

DOM 2 Style

4.6 or later

18

CSS_DIMENSION

A number value of an unknown dimension.

DOM 2 Style

4.6 or later

19

CSS_STRING

A simple string value.

DOM 2 Style

4.6 or later

20

CSS_URI

A string value representing a URI.

DOM 2 Style

4.6 or later

21

CSS_IDENT

A string value representing an identifier.

DOM 2 Style

4.6 or later

22

CSS_ATTR

A string value representing an attribute function.

DOM 2 Style

4.6 or later

23

CSS_COUNTER

A counter or counters function.

DOM 2 Style

4.6 or later

24

CSS_RECT

A Rect function.

DOM 2 Style

4.6 or later

25

CSS_RGBCOLOR

An RGBColor function.

DOM 2 Style

4.6 or later

CSSPrimitiveValue properties

Property name

Type

Description

Status

Support level

Availability

primitiveType

unsigned short

Returns the unit type of a value, represented using a CSSPrimitiveValue constant.

read only

DOM 2 Style

4.6 or later

CSSPrimitiveValue methods

Method name

Description

Support level

Availability

getCounterValue()

Retrieves a Counter value.

DOM 2 Style

4.6 or later

getFloatValue()

Retrieves a float value.

DOM 2 Style

4.6 or later

getRectValue()

Retrieves a Rect value.

DOM 2 Style

4.6 or later

getRGBColorValue()

Retrieves an RGBColor value.

DOM 2 Style

4.6 or later

getStringValue()

Retrieves a string value.

DOM 2 Style

4.6 or later

setFloatValue()

Sets a float value with the specified unit.

DOM 2 Style

4.6 or later

setStringValue()

Sets a string value with the specified unit.

DOM 2 Style

4.6 or later

Previous topic: CSSPageRule properties

Was this information helpful? Send us your comments.