Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

CSS StyleDeclaration length Property

  • Last Updated : 09 Aug, 2019

The length property is used to find the number of style declarations used for the particular element.

Syntax: It is used to return the length property.

Return Value: It returns the number of style declarations specified for an element in the form of integers.

Example: To show the working of the length property:

        CSS StyleDeclaration length Property
        body {
            text-align: center;
        h1 {
            color: green;
    <!-- Adding inline style -->
    <p id="p1" style=" color:green; 
      length Property
      Click the button to 
      return the length property
    <button onclick="myFunction()">
        Get length
    <p id="gfg"></p>
    <!-- Script to get length property -->
        function myFunction() {
            var x = document.getElementById(
            document.getElementById("gfg").innerHTML =
                "Number of styles = " + x;


  • Before clicking on the button:
  • After clicking on the button:

    Supported Browsers: The supported browsers by Style Declaration length Property are listed below:

    • Google Chrome
    • Internet Explorer
    • Firefox
    • Opera
    • Safari

    My Personal Notes arrow_drop_up
  • Recommended Articles
    Page :