Skip to main content

Command Palette

Search for a command to run...

How to implement CSS counter

Published
2 min read
F
I am an Infrastructure and DevOps Engineer specializing in designing, building, and operating scalable, secure, and highly available cloud infrastructure. My core focus is on Microsoft Azure cloud platforms, Infrastructure as Code (IaC), and DevOps automation to support reliable production systems. I work across cloud infrastructure engineering, DevOps practices, and site reliability engineering (SRE) principles to ensure systems are resilient, observable, and optimized for performance, cost, and scalability. My experience includes designing and managing cloud environments across compute, networking, storage, identity, and security layers. I build Infrastructure as Code solutions using Terraform and Azure Resource Manager (ARM) templates to automate provisioning, configuration, and deployment of cloud resources. I am actively involved in improving system reliability through monitoring, logging, and incident response processes using tools such as Azure Monitor and cloud-native observability solutions. I also participate in on-call operations, production support, and incident management to ensure high availability of critical systems. Security is a core part of my engineering approach. I work with identity and access management (IAM), Azure Active Directory, and cloud security best practices to ensure infrastructure remains compliant, secure, and audit-ready in line with industry standards such as ISO 9001 and ISO 27001. I collaborate with cross-functional teams including software engineers, DevSecOps, and product teams to deliver infrastructure solutions for customer-facing applications and enterprise platforms. My technical interests and growth areas include: Cloud Infrastructure Engineering (Azure, AWS, GCP) Site Reliability Engineering (SRE) Platform Engineering Kubernetes & Container Orchestration Infrastructure as Code (Terraform, ARM) CI/CD Pipeline Automation Distributed Systems & System Design Cloud Security & Identity Management I am passionate about building systems that are not only scalable and efficient but also reliable and easy for engineers to use. I am continuously growing my expertise toward senior-level Infrastructure, SRE, and Platform Engineering roles, including global remote opportunities.

Brief explanations with code sample:

Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used.

You can create an ordered list using any type of HTML.

  • counter-reset Initializes a counter, the value is the name of the counter. By default, the counter starts at 0. This property can also be used to change its value to any specific number.

  • counter-increment Used in element that will be countable. Once counter-reset initialized, a counter's value can be increased or decreased.

  • counter(name, style) displays the value of a section counter. Generally used in a content property. This function can receive two parameters, the first as the name of the counter and the second one can be decimal or upper-roman (decimal by default).

  • counters(counter, string, style) displays the value of a section counter. Generally used in a content property. This function can receive three parameters, the first as the name of the counter, the second one you can include a string which comes after the counter and the third one can be decimal or upper-roman (decimal by default).

  • A CSS counter can be especially useful for making outlined lists, because a new instance of the counter is automatically created in child elements. Using the counters() function, separating text can be inserted between different levels of nested counters.

Code Sample:

HTML

<ul>
  <li>List item</li>
  <li>List item</li>
  <li>
    List item
    <ul>
      <li>List item</li>
      <li>List item</li>
      <li>List item</li>
    </ul>
  </li>
</ul>

CSS

ul {
  counter-reset: counter;
}

li::before {
  counter-increment: counter;
  content: counters(counter, '.') ' ';
}

Output:

Screenshot from 2022-04-02 12-42-08.png

Thanks for reading....

Happy Coding!

More from this blog

Building Reliable Systems

93 posts

Insights on Infrastructure, DevOps, SRE, and building reliable systems at scale.