You are here: Reference > JavaScript > client-side > style handling > properties > length (style, currentStyle, ...)

length property (style, currentStyle, ...)

Browser support:
Returns the number of properties that have been set in the current style object.
To get the contents of a style object as a string, use the cssText property.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that represents the number of properties.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the length property:
    <script type="text/javascript">
        function GetBodyStyleLength () {
            alert (;
            alert (;
<body style="color:red; background-color:#e0a0a0;">
    <button onclick="GetBodyStyleLength ();">Get the style length of the body</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

User Contributed Comments

Post Content

Post Content