Hostgator coupons for up to 99% off hosting for Dynamic Drive visitors!
Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library

CSS Library: Other: Here

Customizing Order List style using CSS

Author: Dynamic Drive

Styling the automatically generated number counters in ordered lists (<ol>) can be challenging. This CSS code demonstrates one way to do it by getting rid of the default ones first, then using CSS generated content to create custom counters instead. Specifically, we turn to CSS generated counters, using the "before:" pseudo element and setting its content to "counter". The result is custom counters that can be styled using all the powers of CSS! The custom style works in all modern browsers- IE9+, FF, Chrome, Safari etc.

In the below demo, each level of OL carries a slightly varied style from that of its' parent's (up to the 3rd level).

  1. this is a list 1
  2. this is a list 1
    1. this is a list 2
    2. this is a list 2
      1. this is a list 3
      2. this is a list 3
      3. this is a list 3
      4. this is a list 3
    3. this is a list 2
    4. this is a list 2
  3. this is a list 1
  4. this is a list 1
  5. this is a list 1

The CSS:


Code Info

Rate this code:

Date Posted: 12/03/2012

Revision History: None

Usage Terms: Click here

Your Comments (0)

Got a question or need help customizing this CSS code? Post it in the CSS Forums. If you have a comment or suggestion instead, post it in the comments section below.

Commenting is not available in this weblog entry.
Copyright 2006-2015 Dynamic Drive Read our Usage Terms before using any of the CSS codes.