{"id":248040,"date":"2016-11-21T08:02:13","date_gmt":"2016-11-21T15:02:13","guid":{"rendered":"http:\/\/css-tricks.com\/?p=248040"},"modified":"2018-05-19T09:03:05","modified_gmt":"2018-05-19T16:03:05","slug":"style-list-markers-css","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/style-list-markers-css\/","title":{"rendered":"Style List Markers in CSS"},"content":{"rendered":"

It’s a perfectly reasonable to want to style the marker of list items. You know: blue bullets with black text in an unordered list. Or red counters with knockout white numbers in an ordered list.<\/p>\n

There is a working draft spec<\/a> that defines a ::marker<\/code> pseudo-element that would give us this control.<\/p>\n

\/* Not supported anywhere; subject to change *\/\r\nli::marker {\r\n  color: blue;\r\n}<\/code><\/pre>\n

It’s possible to do this styling now, though, thanks to CSS counters. The trick is to remove the list-style<\/code>, then apply the markers through pseudo-element counters.<\/p>\n

ol {\r\n  list-style: none;\r\n  counter-reset: my-awesome-counter;\r\n}\r\nli {\r\n  counter-increment: my-awesome-counter;\r\n}\r\nli::before {\r\n  content: counter(my-awesome-counter);\r\n\r\n  \/* Style away! *\/\r\n\r\n}<\/code><\/pre>\n

See the Pen Styled List Counters<\/a> by Chris Coyier (@chriscoyier<\/a>) on CodePen<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

It’s a perfectly reasonable to want to style the marker of list items. You know: blue bullets with black text in an unordered list. Or red counters with knockout white numbers in an ordered list. There is a working draft spec that defines a ::marker pseudo-element that would give us this control. \/* Not supported […]<\/p>\n","protected":false},"author":3,"featured_media":271400,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[4],"tags":[918,919],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2016\/11\/styled-list-items.png?fit=1200%2C600&ssl=1","jetpack-related-posts":[{"id":298638,"url":"https:\/\/css-tricks.com\/finally-it-will-be-easy-to-change-the-color-of-list-bullets\/","url_meta":{"origin":248040,"position":0},"title":"Finally, it Will Be Easy to Change the Color of List Bullets","date":"November 14, 2019","format":false,"excerpt":"In my germinating years, the general advice was this: List item li { color: red; } \/* bullet *\/ li span { color: black; } \/* text *\/ Not terrible, but not great. You're \"resetting\" everything at the span level, so it gets more complicated the more you do. Things\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2019\/11\/shapes-and-stuff.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":312104,"url":"https:\/\/css-tricks.com\/how-to-reverse-css-custom-counters\/","url_meta":{"origin":248040,"position":1},"title":"How to Reverse CSS Custom Counters","date":"June 11, 2020","format":false,"excerpt":"I needed a numbered list of blog posts to be listed with the last\/high first and going down from there. Like this: 5. Post Title 4. Post Title 3. Post Title 2. Post Title 1. Post Title But the above is just text. I wanted to do this with a\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2020\/06\/css-counter-reversed.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":270643,"url":"https:\/\/css-tricks.com\/css-counters-custom-list-number-styling\/","url_meta":{"origin":248040,"position":2},"title":"Using CSS Counters for Custom List Number Styling","date":"May 18, 2018","format":false,"excerpt":"How about a classic CSS trick! Getting custom styling on lists isn't even so tricky anymore, since CSS counters have introduced\u00a0counter-increment and counter-reset, and that is perfect for this. I just wanted to make sure you knew how it works and had some easy-to-copy examples at the ready. Let's say\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2018\/05\/custom-list-style.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339298,"url":"https:\/\/css-tricks.com\/list-markers-and-string-styles\/","url_meta":{"origin":248040,"position":3},"title":"List Markers and String Styles","date":"April 29, 2021","format":false,"excerpt":"Lists\u2014we\u2019ve all worked with them in one form or another. I\u2019m talking about HTML\u2019s

    and
      . Much of the time, because we desire styling control, we turn off the list\u2019s markers completely with list-style-type: none, and start styling from there. Other times, we choose from a very limited set\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2018\/05\/custom-list-style.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":15358,"url":"https:\/\/css-tricks.com\/numbering-in-style\/","url_meta":{"origin":248040,"position":4},"title":"Numbering In Style","date":"December 5, 2011","format":false,"excerpt":"Chances are if you want to number things in order on a website, the ordered list () is your guy. It also is pretty reasonable that you want to style those numbers. Strangely enough, styling those list numbers isn't a very easy thing to in CSS. Thankfully it's also not\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2011\/12\/numberedrecipe.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":307060,"url":"https:\/\/css-tricks.com\/list-style-recipes\/","url_meta":{"origin":248040,"position":5},"title":"List Style Recipes","date":"May 5, 2020","format":false,"excerpt":"Lists are a fundamental part of HTML! They are useful in things like blog posts for listing out steps, recipes for listing ingredients, or items in a navigation menu. Not only are they an opportunity for styling, but they have accessibility implications. For example, the number of items in a\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2018\/05\/custom-list-style.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2016\/11\/styled-list-items.png?fit=1024%2C512&ssl=1","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/248040"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=248040"}],"version-history":[{"count":2,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/248040\/revisions"}],"predecessor-version":[{"id":248070,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/248040\/revisions\/248070"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/271400"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=248040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=248040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=248040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}