Skip to content
Related Articles

Related Articles

CSSStyleDeclaration item() Method

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 10 Apr, 2019

The item() method is used to return the property name of CSS from a CSS declaration block through index.



Parameters: It accepts a single parameter:

  • index: It is a required parameter that contains a number which represents the index of the CSS property.

Return Value: It returns the name of the CSS property in the form of the string.

Example: To show the working of the item() method:

        body {
            text-align: center;
        h1 {
            color: green;
    <p id="p1"
      item() Method
    <button onclick="myFunction()">
        Get CSS property
    <p id="gfg"></p>
    <!-- Script to get the property -->
        function myFunction() {
            var x =
            var propertyName = x.item(1);
            document.getElementById("gfg").innerHTML =
                "Property at index 1 is " + propertyName;

Before clicking on the button:

After clicking on the button:

Supported Browsers:

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!