tags:

views:

2136

answers:

12

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.

+1  A: 
<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)

Jonathan Arkell
A: 

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.

hal10001
A: 

You'll want to set a "list-style" via CSS, and give it a color: value. Example: ul.colored {list-style: color: green;}

ahockley
A: 

Just use CSS:

<li style='color:#e0e0e0'>something</li>
Diodeus
Yeah that's what I thought too... but styling li color changes the color of the text as well as the bullet.
Aeon
+16  A: 

The bullet gets its color from the text. So if you want to have a different color bullet than text in your list you'll have to add some markup.

Wrap the list text in a span:

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

Then modify your style rules slightly:

li {
  color: red; /* bullet color */
}
li span {
  color: black /* text color */
}
Prestaul
Exactly what I needed! I have a list of links and the links already have a different color style applied to them anyway.
Elmo Gallen
+1 good answer @Prestaul
metal-gear-solid
+1  A: 

this

  li:before {
   color: pink;
  }

was suggested here

Lou Franco
Don't think this will work if your list item was wrapped in something, like a strong or anchor tag.
JannieT
A: 

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!

Aeon
A: 
<ul style="color: red;">
<li>One</li>
<li>Two></li>
<li>Three</li>
</ul>
  • One
  • Two>
  • Three
  • NerdFury
    A: 
    <ul>
    <li style="color:#ddd;"><span style="color:#000;">List Item</span></li>
    </ul>
    
    A: 

    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.

    A: 

    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>
    
    A: 

    There is a really good article on this at JohnNemec.com - maybe that might clear up some confusion.