Home > Web Front-end > CSS Tutorial > How Can I Create an HTML Ordered List with Lower-Alpha Markers and Right Parentheses?

How Can I Create an HTML Ordered List with Lower-Alpha Markers and Right Parentheses?

DDD
Release: 2024-11-24 09:57:13
Original
999 people have browsed it

How Can I Create an HTML Ordered List with Lower-Alpha Markers and Right Parentheses?

Ordered Lists in HTML: Lower-Alpha with Right Parentheses

The standard ordered list type for "lower-alpha" uses a period "." as the list marker. Is there a way to modify this to use a right parenthesis instead, resulting in a sequence like a)... b) etc.?

Solution

CSS offers a feature called counters, which allows for the automatic creation of sequences such as chapter numbers. By adapting this concept, we can achieve our desired lower-alpha list with right parentheses.

Here's a code snippet:

ol {
  counter-reset: list;
}
ol > li {
  list-style: none;
}
ol > li:before {
  content: counter(list, lower-alpha) ") ";
  counter-increment: list;
}
Copy after login

The "counter-reset" property initializes a counter named "list" for the ordered list. "list-style: none;" removes the native list symbols.

The key step is the "li:before" selector. It inserts content before each list item:

  • "counter(list, lower-alpha)" counts using lower-alpha characters (a), b), etc.).
  • Adding a closing parenthesis and a space creates the desired format: a)

The resulting list will appear as follows:

`Custom list style type (v1):


  1. Number 1

  2. Number 2

  3. Number 3

  4. Number 4

  5. Number 5

  6. Number 6

`

The above is the detailed content of How Can I Create an HTML Ordered List with Lower-Alpha Markers and Right Parentheses?. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template