Home > Web Front-end > CSS Tutorial > How to Fix Nested Ordered List Numbering Issues in HTML?

How to Fix Nested Ordered List Numbering Issues in HTML?

Linda Hamilton
Release: 2024-11-17 21:12:01
Original
615 people have browsed it

How to Fix Nested Ordered List Numbering Issues in HTML?

HTML Ordered Lists: Nested Counters and Scope Issues

In HTML, using CSS counters and scope can help create structured ordered lists. However, sometimes issues arise when attempting to nest these counters.

The Problem

When setting up nested ordered lists with counters, some may encounter incorrect numbering in the child lists. Instead of the expected nested structure, the numbering may continue incrementally from the parent list upon returning to it.

The Solution

To address this issue, ensure that the Normalize CSS is disabled. In older browsers, this CSS reset often sets all list margins and paddings to zero, leading to alignment problems. Alternatively, nesting the sub-lists within the main

  • elements can resolve the issue.

    Example

    <ol>
      <li>one</li>
      <li>two
        <ol>
          <li>two.one</li>
          <li>two.two</li>
          <li>two.three</li>
        </ol>
      </li>
      <li>three
        <ol>
          <li>three.one</li>
          <li>three.two
            <ol>
              <li>three.two.one</li>
              <li>three.two.two</li>
            </ol>
          </li>
        </ol>
      </li>
      <li>four</li>
    </ol>
    Copy after login

    The above is the detailed content of How to Fix Nested Ordered List Numbering Issues in HTML?. For more information, please follow other related articles on the PHP Chinese website!

  • source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Latest Articles by Author
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template