• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Css Basic: counter-reset

December 20, 2023

CSS Basics: counter-reset

In CSS, the counter-reset property is used to reset the value of a CSS counter to a specified value. This property is often used in conjunction with the counter-increment property to create custom counters for various elements on a webpage.

How counter-reset Works

The counter-reset property is used to reset the value of a counter to a specified value. It takes two values: the name of the counter and the value to which it should be reset. The counter name is defined using the counter-name property, and the value is defined using the counter-value property.

Here’s an example:

body {
  counter-reset: my-counter 0;
}

h1 {
  counter-reset: my-counter 1;
}

In this example, we define a counter named my-counter and reset it to 0 for the body element. Then, we reset it to 1 for all h1 elements. This means that the counter will start at 0 for the body element and increment by 1 for each h1 element.

Using counter-reset with counter-increment

The counter-reset property is often used in conjunction with the counter-increment property to create custom counters. The counter-increment property is used to increment the value of a counter by a specified amount.

Here’s an example:

body {
  counter-reset: my-counter 0;
}

h1 {
  counter-increment: my-counter 1;
}

h2 {
  counter-increment: my-counter 2;
}

In this example, we define a counter named my-counter and reset it to 0 for the body element. Then, we increment it by 1 for each h1 element and by 2 for each h2 element. This means that the counter will start at 0 for the body element, increment by 1 for each h1 element, and increment by 2 for each h2 element.

Conclusion

The counter-reset property in CSS is a powerful tool for creating custom counters on webpages. By using this property in conjunction with the counter-increment property, you can create unique and dynamic counters for various elements on your website.

If you’re interested in learning more about VPS hosting and how it can benefit your website, consider checking out Server.HK. They offer top-notch VPS solutions that can help improve the performance and reliability of your website.

Recent Posts

  • How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)
  • How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  • CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  • Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  • Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot