Ordered list (HTML) lower-alpha with right parentheses?
Create a lower-alpha ordered list with right parentheses using CSS custom counters:
Complement this CSS snippet with a simple HTML ordered list (<ol>
):
This concoction of CSS and HTML produces an ordered list with fashionable markers like 'a)', 'b)', and beyond.
Making marker alignment great again
When opting for custom counters, you might need to align the markers. Achieve a tailored alignment using CSS positional properties:
This ensures a tidy left alignment for your list markers—it's like having your own personal typographer!
One nest does not make a summer: Handling nested lists
Nested ol's can cause style inheritance from parent, presenting you some unwanted surprises. Nip them in the bud with child selectors:
This approach ensures that the nested lists maintain their original style.
Taking control with @counter-style
For those who love to play with advanced features, create a personalized @counter-style
:
Then you can apply it using list-style-type
:
Just remember to cross-check browser compatibility for @counter-style
, as not all browsers (especially Safari) are ready for high fashion.
Visualising the outcome
A side-by-side comparison often clarifies the difference between standard and customized list markers:
Type | Standard | Customized |
---|---|---|
List Marker | 1. | a) |
2. | b) | |
3. | c) |
The transformation from numbered to alphabetic markers is as easy as ABC) D) E).
Turn the 'content' knob for amazing results
CSS content
property is your pro mixer's knob to play with different effects. You can use it to add special characters, symbols, or even words:
Test drive your customized list
While it's fun to get creative with lists, make sure the end result is user-friendly. Always check your list in different contexts to ensure it is easily readable and visually accessible. Remember, a good design is good business!
Was this article helpful?