Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6994053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:50:35+00:00 2026-05-27T19:50:35+00:00

I’m running into a bit of a problem using the css content property to

  • 0

I’m running into a bit of a problem using the css “content” property to create an ordered list that has been styled to display using decimals for more deeply nested items. What I’m trying to do seems like an obvious task, but I haven’t succeeded yet, and I’m running into some cross browser issues, but I can’t seem to find much poking around the internets… What I’m trying to do is spelled out pretty clearly in the image I’ve attached at the bottom of this question.

My CSS:

ol {list-style:none; font:11px arial; margin:0px 0px 0px 10px; padding:0;}

ol li:before {
        content: counter(num) ". ";
        counter-increment: num;
        counter-reset: sub_num;
}

ol ol li:before {
        content: counter(num) "." counter(sub_num)  " ";
        counter-increment: sub_num; 
        counter-reset: sub_sub_num;
}
ol ol ol li:before {
        content: counter(num) "." counter(sub_num)  "." counter(sub_sub_num) " ";
        counter-increment: sub_sub_num; 
        counter-reset:none;
}

My HTML:

<ol>
    <li>Level 1 - should be '1.'</li>
    <li>Level 1 - should be '2.'
      <ol>
        <li>Level 2 - Should be '2.1'</li>
        <li>Level 2 - Should be '2.2'
          <ol>
            <li>Level 3 - Should be '2.2.1'</li>

            <li>Level 3 - Should be '2.2.2'</li>
          </ol>
        </li>
      </ol>
    </li>
    <li>Level 1 - should be '3.'
      <ol>
        <li>Level 2 - Should be '3.1'</li>
      </ol>
    </li>
</ol>

My Outcomes

Unfortunately, the css isn’t incrementing the ‘num’ variable

counter-increment: num;

in any browser, and Chrome isn’t incrementing ‘sub_sub_num’

counter-increment: sub_sub_num; 

I’m a little baffled, as it seems that all the browsers are being internally inconsistent with how they’re handling the styles (why would all browsers ignore the num increment, but accept the sub_num increment?) and it’s a little surprising the firefox and ie have the same behavior, whereas chrome seems to be handling it particularly badly (i’m used to ie being the odd man out).

Here’s an image with the outputs of my sample for ff8, chrome16, and ie8 which shows the outputs I’m seeing, along with a user agent string:

Issues with the css content property

Am I just missing something, or is this an understood issue? Are there any good implementations out there?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:50:35+00:00Added an answer on May 27, 2026 at 7:50 pm

    There is a convenient function called counters() that handles all this automatically for you — simply pass in the num variable and the period symbol as the separator. You don’t have to create or increment any other variables.

    You also forgot to reset num in your top-level ol element.

    Here’s the CSS that you need:

    ol {
        list-style: none; 
        font: 11px arial; 
        margin: 0px 0px 0px 10px; 
        padding: 0;
        counter-reset: num;
    }
    
    ol li:before {
        content: counter(num) '. ';
        counter-increment: num;
    }
    
    ol ol li:before {
        content: counters(num, '.') ' ';
    }
    

    jsFiddle demo

    If you’d like to understand how to use multiple counters with nested lists, this answer demonstrates something a little more complex. The idea is to reset your counters in the parent ol elements and increment them in their respective child li:before pseudo-elements; in your case, you’re doing both in the li:before pseudo-elements, which isn’t quite correct.

    Useful reading: W3C CSS2.1 generated content spec, §12.4.1 Nested counters and scope

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to create an if statement in PHP that prevents a single post
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.