Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
HTML | DOM Style counterIncrement Property
Next article icon

HTML | DOM Style counterIncrement Property

Last Updated : 08 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The Style counterIncrement property in HTML DOM specifies how much the counter should be incremented on each occurrence of a selector. The Default value for an increment is 1. 

Syntax: 

  • Return the counterIncrement property:
object.style.counterIncrement
  • Set the counterIncrement property:
object.style.counterIncrement = "none|number|initial|inherit"

Property Values: 

  • None: It is the default value. This value does not reset the counter.
  • Number: Sets an increment for the named counter each time the element appears. This increment can be zero, or even negative. The default value is 1 if not specified.
  • Initial: Sets the element to its initial position.
  • Inherit: The Element inherits its property from the parent element.

Example-1: Change counterIncrement Property. 

html
<!DOCTYPE html> <html lang="en">  <head>     <title>         HTML | DOM Style counterIncrement Property     </title>     <style type="text/css">         body {             counter-reset: section;         }                  h1 {             color: green;         }                  h2 {             counter-increment: section;         }                  h2:before {             content: "Section "               counter(section) ". ";         }     </style> </head>  <body>     <h1>GeeksForGeeks</h1>     <h2>JavaScript</h2>     <h2 id="h">HTML</h2>     <h2>CSS </h2>     <button onclick="myFunction()">       Check   </button>        <script>         function myFunction() {             document.getElementById(               "h").style.counterIncrement =                "subsection";         }     </script> </body>  </html> 

Output: 
Before: 

After: 

Example- 2: counterIncrement Property. 

html
<!DOCTYPE html> <html lang="en">  <head>     <title>         HTML | DOM Style counterIncrement Property     </title>     <style type="text/css">         body {             counter-reset: section;         }                  h1 {             color: green;         }                  h2 {             counter-increment: section;         }                  h2:before {             content:                "Section " counter(section) ". ";         }                  h3:before {             counter-increment: category;             content: counter(section) "." counter(category) " ";         }     </style> </head>  <body>     <h1>GeeksForGeeks</h1>     <h2>Javascript</h2>     <h2 id="h">HTML</h2>     <h2 id="H">CSS </h2>     <h2>References</h2>     <h3>HTML Tags</h3>     <h3>CSS Properties</h3>     <button onclick="myFunction()"             >Check 1   </button>        <button onclick="Function()">       Check 2   </button>        <script>         function myFunction() {             document.getElementById(               "h").style.counterIncrement =                "subsection";         }          function Function() {             document.getElementById(               "H").style.counterIncrement =                "subsection";         }     </script> </body>  </html> 

Output: 
Before: 

After first check: 

After second check: 

Supported Browsers: The browser supported by HTML | DOM Style counter Increment Property are listed below: 

  • Google Chrome 2 and above
  • Edge 12 and above
  • Internet Explorer 8 and above
  • Firefox 1 and above
  • Opera 9.2 and above
  • Safari 3 and above

Next Article
HTML | DOM Style counterIncrement Property

C

ChinkitManchanda
Improve
Article Tags :
  • Web Technologies
  • HTML
  • HTML-DOM

Similar Reads

    HTML | DOM Style counterReset Property
    The Style counterReset property in HTML DOM is used to create or reset counters. This property is used with the counterincrement property and the content property.Syntax: It is used to return the counterReset property. object.style.counterResetIt is used to set the counterReset property. object.styl
    1 min read
    HTML | DOM Style columnCount Property
    The DOM Style columnCount property specifies a number that defines the number of columns an element should be divided into. Syntax : To return the value: object.style.columnCount To set the value: object.style.columnCount = "number|auto|initial|inherit" Property Values: number: Specifies the number
    4 min read
    HTML DOM Style animationIterationCount Property
    The Style animationIterationCount property in HTML DOM is used to set or return how many times an animation should be played. Syntax: It is used to return the animationIterationCount property.object.style.animationIterationCountIt is used to set the animationIterationCount property.object.style.anim
    2 min read
    CSS counter-increment Property
    The CSS counter-increment Property is used to increment/decrement value of a counter. A CSS counter is a variable that is used to track how many times a variable is used. Syntax: counter-increment: none | identifier | initial | inherit;Default Value: none Property values:none: This is the default va
    4 min read
    HTML DOM children Property
    The DOM children property is used to return an HTML collection of all the child elements of the specified element. The elements in the collection can be accessed by index numbers. It differs from childNodes as childNodes contain all nodes (i.e. it includes text and comment nodes as well) but on the
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences