Thursday, October 1, 2009

CSS for numbered sublists

I ran across a nice piece of CSS to add numbered subitems in an ordered list.

ol { counter-reset: item }

li { display: block }

li:before { content: counters(item, ".") " "; counter-increment: item }

That's pretty simple! You can play around with HTML lists here.

There's also the jQuery route (with example), but it isn't as simple or lightweight, and it isn't recursive.

No comments:

Post a Comment