[html] Change the color of a bullet in a html list?

All I want is to be able to change the color of a bullet in a list to a light gray. It defaults to black, and I can't figure out how to change it.

I know I could just use an image; I'd rather not do that if I can help it.

This question is related to html css html-lists

The answer is


As per W3C spec,

The list properties ... do not allow authors to specify distinct style (colors, fonts, alignment, etc.) for the list marker ...

But the idea with a span inside the list above should work fine!


You could use CSS to attain this. By specifying the list in the color and style of your choice, you can then also specify the text as a different color.

Follow the example at http://www.echoecho.com/csslists.htm.


It works as well if we set color for each elements for example: I added some Margin to left now.

<article class="event-item">
    <p>Black text here</p>
</article>

.event-item{
    list-style-type: disc;
    display: list-item;
    color: #ff6f9a;
     margin-left: 25px;
}
.event-item p {
    margin: 0;
    color: initial;
}

I managed this without adding markup, but instead using li:before. This obviously has all the limitations of :before (no old IE support), but it seems to work with IE8, Firefox and Chrome after some very limited testing. It's working in our controller environment, wondering if anyone could check this. The bullet style is also limited by what's in unicode.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <style type="text/css">
    li {
      list-style: none;
    }

    li:before {
      /* For a round bullet */
      content:'\2022';
      /* For a square bullet */
      /*content:'\25A0';*/
      display: block;
      position: relative;
      max-width: 0px;
      max-height: 0px;
      left: -10px;
      top: -0px;
      color: green;
      font-size: 20px;
    }
  </style>
</head>

<body>
  <ul>
    <li>foo</li>
    <li>bar</li>
  </ul>
</body>
</html>

Wrap the text within the list item with a span (or some other element) and apply the bullet color to the list item and the text color to the span.


This was impossible in 2008, but it's becoming possible soon (hopefully)!

According to The W3C CSS3 specification, you can have full control over any number, glyph, or other symbol generated before a list item with the ::marker pseudo-element. To apply this to the most voted answer's solution:

<ul>
  <li>item #1</li>
  <li>item #2</li>
  <li>item #3</li>
</ul>

li::marker {
  color: red; /* bullet color */
}
li {
  color: black /* text color */
}

JSFiddle Example

Note, though, that as of July 2016, this solution is only a part of the W3C Working Draft and does not work in any major browsers, yet.

If you want this feature, do these:


Just use CSS:

<li style='color:#e0e0e0'>something</li>

You'll want to set a "list-style" via CSS, and give it a color: value. Example:

ul.colored {list-style: color: green;}

<ul>
  <li style="color: #888;"><span style="color: #000">test</span></li>
</ul>

the big problem with this method is the extra markup. (the span tag)


<ul style="color: red;">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
  • One
  • Two
  • Three

  • As per W3C spec,

    The list properties ... do not allow authors to specify distinct style (colors, fonts, alignment, etc.) for the list marker ...

    But the idea with a span inside the list above should work fine!


    <ul>
    <li style="color:#ddd;"><span style="color:#000;">List Item</span></li>
    </ul>
    

    <ul style="color: red;">
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    </ul>
    
  • One
  • Two
  • Three

  • You'll want to set a "list-style" via CSS, and give it a color: value. Example:

    ul.colored {list-style: color: green;}
    

    <ul>
    <li style="color:#ddd;"><span style="color:#000;">List Item</span></li>
    </ul>
    

    For a 2008 question, I thought I might add a more recent and up-to-date answer on how you could go about changing the colour of bullets in a list.

    If you are willing to use external libraries, Font Awesome gives you scalable vector icons, and when combined with Bootstrap's helper classes (eg. text-success), you can make some pretty cool and customisable lists.

    I have expanded on the extract from the Font Awesome list examples page below:

    Use fa-ul and fa-li to easily replace default bullets in unordered lists.

    _x000D_
    _x000D_
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />_x000D_
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />_x000D_
    _x000D_
    <ul class="fa-ul">_x000D_
      <li><i class="fa-li fa fa-circle"></i>List icons</li>_x000D_
      <li><i class="fa-li fa fa-check-square text-success"></i>can be used</li>_x000D_
      <li><i class="fa-li fa fa-spinner fa-spin text-primary"></i>as bullets</li>_x000D_
      <li><i class="fa-li fa fa-square text-danger"></i>in lists</li>_x000D_
    </ul>
    _x000D_
    _x000D_
    _x000D_

    Font Awesome (mostly) supports IE8, and only supports IE7 if you use the older version 3.2.1.


    <ul>
      <li style="color: #888;"><span style="color: #000">test</span></li>
    </ul>
    

    the big problem with this method is the extra markup. (the span tag)


    For a 2008 question, I thought I might add a more recent and up-to-date answer on how you could go about changing the colour of bullets in a list.

    If you are willing to use external libraries, Font Awesome gives you scalable vector icons, and when combined with Bootstrap's helper classes (eg. text-success), you can make some pretty cool and customisable lists.

    I have expanded on the extract from the Font Awesome list examples page below:

    Use fa-ul and fa-li to easily replace default bullets in unordered lists.

    _x000D_
    _x000D_
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />_x000D_
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />_x000D_
    _x000D_
    <ul class="fa-ul">_x000D_
      <li><i class="fa-li fa fa-circle"></i>List icons</li>_x000D_
      <li><i class="fa-li fa fa-check-square text-success"></i>can be used</li>_x000D_
      <li><i class="fa-li fa fa-spinner fa-spin text-primary"></i>as bullets</li>_x000D_
      <li><i class="fa-li fa fa-square text-danger"></i>in lists</li>_x000D_
    </ul>
    _x000D_
    _x000D_
    _x000D_

    Font Awesome (mostly) supports IE8, and only supports IE7 if you use the older version 3.2.1.


    Hello maybe this answer is late but is the correct one to achieve this.

    Ok the fact is that you must specify an internal tag to make the LIst text be on the usual black (or what ever you want to get it). But is also true that you can REDEFINE any TAGS and internal tags with CSS. So the best way to do this use a SHORTER tag for the redefinition

    Usign this CSS definition:

    li { color: red; }
    li b { color: black; font_weight: normal; }
    .c1 { color: red; }
    .c2 { color: blue; }
    .c3 { color: green; }
    

    And this html code:

    <ul>
    <li><b>Text 1</b></li>
    <li><b>Text 2</b></li>
    <li><b>Text 3</b></li>
    </ul>
    

    You get required result. Also you can make each disc diferent color:

    <ul>
        <li class="c1"><b>Text 1</b></li>
        <li class="c2"><b>Text 2</b></li>
        <li class="c3"><b>Text 3</b></li>
     </ul>
    

    Just do a bullet in a graphics program and use list-style-image:

    ul {
      list-style-image:url('gray-bullet.gif');
    }
    

    This was impossible in 2008, but it's becoming possible soon (hopefully)!

    According to The W3C CSS3 specification, you can have full control over any number, glyph, or other symbol generated before a list item with the ::marker pseudo-element. To apply this to the most voted answer's solution:

    <ul>
      <li>item #1</li>
      <li>item #2</li>
      <li>item #3</li>
    </ul>
    
    li::marker {
      color: red; /* bullet color */
    }
    li {
      color: black /* text color */
    }
    

    JSFiddle Example

    Note, though, that as of July 2016, this solution is only a part of the W3C Working Draft and does not work in any major browsers, yet.

    If you want this feature, do these:


    <ul style="color: red;">
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    </ul>
    
  • One
  • Two
  • Three

  • Just do a bullet in a graphics program and use list-style-image:

    ul {
      list-style-image:url('gray-bullet.gif');
    }
    

    As per W3C spec,

    The list properties ... do not allow authors to specify distinct style (colors, fonts, alignment, etc.) for the list marker ...

    But the idea with a span inside the list above should work fine!


    Wrap the text within the list item with a span (or some other element) and apply the bullet color to the list item and the text color to the span.


    <ul style="color: red;">
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    </ul>
    
  • One
  • Two
  • Three

  • Just use CSS:

    <li style='color:#e0e0e0'>something</li>
    

    As per W3C spec,

    The list properties ... do not allow authors to specify distinct style (colors, fonts, alignment, etc.) for the list marker ...

    But the idea with a span inside the list above should work fine!


    <ul>
      <li style="color: #888;"><span style="color: #000">test</span></li>
    </ul>
    

    the big problem with this method is the extra markup. (the span tag)


    Just use CSS:

    <li style='color:#e0e0e0'>something</li>
    

    <ul>
    <li style="color:#ddd;"><span style="color:#000;">List Item</span></li>
    </ul>
    

    Wrap the text within the list item with a span (or some other element) and apply the bullet color to the list item and the text color to the span.


    You can use Jquery if you have lots of pages and don't need to go and edit the markup your self.

    here is a simple example:

    $("li").each(function(){
    var content = $(this).html();
    var myDiv = $("<div />")
    myDiv.css("color", "red"); //color of text.
    myDiv.html(content);
    $(this).html(myDiv).css("color", "yellow"); //color of bullet
    });
    

    You could use CSS to attain this. By specifying the list in the color and style of your choice, you can then also specify the text as a different color.

    Follow the example at http://www.echoecho.com/csslists.htm.


    <ul>
      <li style="color: #888;"><span style="color: #000">test</span></li>
    </ul>
    

    the big problem with this method is the extra markup. (the span tag)


    You could use CSS to attain this. By specifying the list in the color and style of your choice, you can then also specify the text as a different color.

    Follow the example at http://www.echoecho.com/csslists.htm.


    You'll want to set a "list-style" via CSS, and give it a color: value. Example:

    ul.colored {list-style: color: green;}
    

    Hello maybe this answer is late but is the correct one to achieve this.

    Ok the fact is that you must specify an internal tag to make the LIst text be on the usual black (or what ever you want to get it). But is also true that you can REDEFINE any TAGS and internal tags with CSS. So the best way to do this use a SHORTER tag for the redefinition

    Usign this CSS definition:

    li { color: red; }
    li b { color: black; font_weight: normal; }
    .c1 { color: red; }
    .c2 { color: blue; }
    .c3 { color: green; }
    

    And this html code:

    <ul>
    <li><b>Text 1</b></li>
    <li><b>Text 2</b></li>
    <li><b>Text 3</b></li>
    </ul>
    

    You get required result. Also you can make each disc diferent color:

    <ul>
        <li class="c1"><b>Text 1</b></li>
        <li class="c2"><b>Text 2</b></li>
        <li class="c3"><b>Text 3</b></li>
     </ul>
    

    You'll want to set a "list-style" via CSS, and give it a color: value. Example:

    ul.colored {list-style: color: green;}
    

    You could use CSS to attain this. By specifying the list in the color and style of your choice, you can then also specify the text as a different color.

    Follow the example at http://www.echoecho.com/csslists.htm.


    Just use CSS:

    <li style='color:#e0e0e0'>something</li>
    

    You can use Jquery if you have lots of pages and don't need to go and edit the markup your self.

    here is a simple example:

    $("li").each(function(){
    var content = $(this).html();
    var myDiv = $("<div />")
    myDiv.css("color", "red"); //color of text.
    myDiv.html(content);
    $(this).html(myDiv).css("color", "yellow"); //color of bullet
    });
    

    It works as well if we set color for each elements for example: I added some Margin to left now.

    <article class="event-item">
        <p>Black text here</p>
    </article>
    
    .event-item{
        list-style-type: disc;
        display: list-item;
        color: #ff6f9a;
         margin-left: 25px;
    }
    .event-item p {
        margin: 0;
        color: initial;
    }
    

    <ul>
    <li style="color:#ddd;"><span style="color:#000;">List Item</span></li>
    </ul>
    

    Examples related to html

    Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

    Examples related to css

    need to add a class to an element Using Lato fonts in my css (@font-face) Please help me convert this script to a simple image slider Why there is this "clear" class before footer? How to set width of mat-table column in angular? Center content vertically on Vuetify bootstrap 4 file input doesn't show the file name Bootstrap 4: responsive sidebar menu to top navbar Stylesheet not loaded because of MIME-type Force flex item to span full row width

    Examples related to html-lists

    How to markdown nested list items in Bitbucket? how do I get the bullet points of a <ul> to center with the text? Is there a way to make numbers in an ordered list bold? How to center an unordered list? How do I set vertical space between list items? Removing "bullets" from unordered list <ul> jQuery load first 3 elements, click "load more" to display next 5 elements How can I disable a specific LI element inside a UL? UL has margin on the left How to display an unordered list in two columns?