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 748153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:17:14+00:00 2026-05-14T14:17:14+00:00

I have a nested ordered list. <ol> <li>first</li> <li>second <ol> <li>second nested first element</li>

  • 0

I have a nested ordered list.

<ol>
  <li>first</li>
  <li>second
  <ol>
    <li>second nested first element</li>
    <li>second nested secondelement</li>
    <li>second nested thirdelement</li>
  </ol>
  </li>
  <li>third</li>
  <li>fourth</li>
</ol>

Currently the nested elements start back from 1 again, e.g.

  1. first
  2. second
    1. second nested first element
    2. second nested second element
    3. second nested third element
  3. third
  4. fourth

What I want is for the second element to be numbered like this:

  1. first
  2. second

    2.1. second nested first element

    2.2. second nested second element

    2.3. second nested third element

  3. third
  4. fourth

Is there a way of doing this?

  • 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-14T14:17:15+00:00Added an answer on May 14, 2026 at 2:17 pm

    Here’s an example which works in all browsers. The pure CSS approach works in the real browsers (i.e. everything but IE6/7) and the jQuery code is to cover the unsupported. It’s in flavor of an SSCCE, you can just copy’n’paste’n’run it without changes.

    <!doctype html>
    <html lang="en">
        <head>
            <title>SO question 2729927</title>
            <script src="http://code.jquery.com/jquery-latest.min.js"></script>
            <script>
                $(document).ready(function() {
                    if ($('ol:first').css('list-style-type') != 'none') { /* For IE6/7 only. */
                        $('ol ol').each(function(i, ol) {
                            ol = $(ol);
                            var level1 = ol.closest('li').index() + 1;
                            ol.children('li').each(function(i, li) {
                                li = $(li);
                                var level2 = level1 + '.' + (li.index() + 1);
                                li.prepend('<span>' + level2 + '</span>');
                            });
                        });
                    }
                });
            </script>
            <style>
                html>/**/body ol { /* Won't be interpreted by IE6/7. */
                    list-style-type: none;
                    counter-reset: level1;
                }
                ol li:before {
                    content: counter(level1) ". ";
                    counter-increment: level1;
                }
                ol li ol {
                    list-style-type: none;
                    counter-reset: level2;
                }
                ol li ol li:before {
                    content: counter(level1) "." counter(level2) " ";
                    counter-increment: level2;
                }
                ol li span { /* For IE6/7. */
                    margin: 0 5px 0 -25px;
                }
            </style>
        </head>
        <body>
            <ol>
                <li>first</li>
                <li>second
                    <ol>
                        <li>second nested first element</li>
                        <li>second nested second element</li>
                        <li>second nested third element</li>
                    </ol>
                </li>
                <li>third</li>
                <li>fourth</li>
            </ol>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nested ordered list with this structure <ol> <li> <span>A</span> <ol class=childol>
I have several definition lists each containing a nested ordered list and anchor. On
I have a nested oredered list which i m animating using this code... var
I have nested list of the following form: my_list = [['Some1', '2', '3.6', '4.5',
I have a nested drag and drop list which return json formattet string. I
I want to scrape some html pages that have nested form elements with lxml.
I have a LINQ query which is fetching a list of nested objects. from
I have nested each loops but an Ajax request in the second loop seems
I use nested counters and scope to create an ordered list: ol { counter-reset:
Suppose I have a list of nodes which represent a nested set hierachy (examples

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.