{"id":627,"date":"2012-08-02T08:41:56","date_gmt":"2012-08-02T07:41:56","guid":{"rendered":"http:\/\/gavtaylor.co.uk\/blog\/?p=627"},"modified":"2012-08-02T14:33:06","modified_gmt":"2012-08-02T13:33:06","slug":"coloured-bullets-in-list-items","status":"publish","type":"post","link":"https:\/\/gavtaylor.uk\/blog\/coloured-bullets-in-list-items","title":{"rendered":"Coloured bullets in List items"},"content":{"rendered":"<p>As we all make the move to HTML5 and less images in our code for gradients, fonts, box\/text shadow, etc. One thing I have yet to find a solution for is coloured bullets on a list item, that is until now.<\/p>\n<p>There isn&#8217;t a list-style-color, or a similar way of specifying a colour for a list bullet in the CSS spec, so up till now its been a case of either set the colour on the &lt;li&gt; and wrap a span around your text in an other colour, or use a background image. I have tended to go for the image as you can have a different size bullet to the default one.<\/p>\n<p>Today I was pottering around and came up with a handy trick for doing a coloured square in CSS, of any size or colour you fancy and using any Unicode character you can find. I am writing here so I remember and hopefully one or two of you may find useful. It doesn&#8217;t work in IE6\/7 but does fall-back to the standard &lt;li&gt; bullet in the colour of your text, so that&#8217;s good enough for me.<\/p>\n<h3>HTML<\/h3>\n<p><code>&lt;ul&gt;<br \/>\n&lt;li&gt;This is an item in a list&lt;\/li&gt;<br \/>\n&lt;li&gt;You may have guessed but this is too&lt;\/li&gt;<br \/>\n&lt;li&gt;Your on a roll, yes this is another list item&lt;\/li&gt;<br \/>\n&lt;li&gt;Almost finished...&lt;\/li&gt;<br \/>\n&lt;li&gt;One more for the road&lt;\/li&gt;<br \/>\n&lt;\/ul&gt;<\/code><\/p>\n<h3>CSS<\/h3>\n<p><code>ul.custom-bullet-demo li {<br \/>\nlist-style: square;<br \/>\nfont-size: 16px;<br \/>\n}<br \/>\nul.custom-bullet-demo li:before {<br \/>\ncolor: #B9D851;<br \/>\ncontent: \"\\25A0\";<br \/>\nfont-size: 1.7em;<br \/>\nmargin-left: -19px;<br \/>\npadding-right: 0.25em;<br \/>\nposition: relative;<br \/>\n}<\/code><\/p>\n<h3>Result<\/h3>\n<style>\nul.custom-bullet-demo li {\nlist-style: square;\nfont-size: 16px;\n}\nul.custom-bullet-demo li:before {\ncolor: #B9D851;\ncontent: \"\\25A0\";\nfont-size: 1.7em;\nmargin-left: -19px;\npadding-right: 0.25em;\nposition: relative;\n}\n<\/style>\n<ul class=\"custom-bullet-demo\">\n<li>This is an item in a list<\/li>\n<li>You may have guessed but this is too<\/li>\n<li>Your on a roll, yes this is another list item<\/li>\n<li>Almost finished&#8230;<\/li>\n<li>One more for the road<\/li>\n<\/ul>\n<p>I found a Wikepedia page that has a few Unicode characters on it so you can use all sorts of bullets rather than the standard square or circle (except for IE6\/7 that is).<\/p>\n<p>&#8211; http:\/\/en.wikipedia.org\/wiki\/List_of_Unicode_characters<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we all make the move to HTML5 and less images in our code for gradients, fonts, box\/text shadow, etc. One thing I have yet to find a solution for is coloured bullets on a list item, that is until now. There isn&#8217;t a list-style-color, or a similar way of specifying a colour for a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[43],"tags":[255,253,304,254],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/posts\/627"}],"collection":[{"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/comments?post=627"}],"version-history":[{"count":18,"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/posts\/627\/revisions"}],"predecessor-version":[{"id":646,"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/posts\/627\/revisions\/646"}],"wp:attachment":[{"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/media?parent=627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/categories?post=627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gavtaylor.uk\/blog\/wp-json\/wp\/v2\/tags?post=627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}