April 14, 2008

<UL> Bullet Coloring with CSS

Filed under: CSS, XHTML — Soleer @ 9:30 am

As we know, designers can never leave well enough alone.  The default css behavior is for bullets to be the same color as their associated list item <li>.  Although there are a number of solutions on the internet, this is the most simple, elegant, and universally compatible.

 Here is an example of what we’re looking to accomplish:

  • Bullet-List Item 1
  • Bullet-List Item 2
  • Bullet-List Item 3
  • Bullet-List Item 4
  • Bullet-List Item 5

Note how the bullets are red and the list-item text is blue.  Now, let’s take a look at the code:

Standard code:

<ul id=”ex_list”>
      <li>Bullet-List Item 1</li>
      <li>Bullet-List Item 2</li>
      <li>Bullet-List Item 3</li>
      <li>Bullet-List Item 4</li>
      <li>Bullet-List Item 5</li>
</ul>

In order to style the bullets and text seperately, we must enclose the <li> text within <span> tags:

<ul id=”ex_list”>
      <li><span>Bullet-List Item 1</span></li>
      <li><span>Bullet-List Item 2</span></li>
      <li><span>Bullet-List Item 3</span></li>
      <li><span>Bullet-List Item 4</span></li>
      <li><span>Bullet-List Item 5</span></li>
</ul>

Now that we have the xhtml setup correctly, all we have to do is perform some minor CSS changes:

#ex_list li{
          color: blue;       /* The color you want the bullets to be */
}
#ex_list li span{
          color: red;      /* The color you want the bullets to be */
}

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Who we are

Explore our history and character.

If you've ever been on a blind-date, odds are great that you know how disastrous "jumping before looking" can be. Feel free to do some online stalking here before you contact Soleer.

What We Do

"Girls only want boyfriends who have great skills." -Napoleon Dynamite

While we aren't looking to be your boyfriend and might not have "nunchuku skills," we do offer a number of other services and solutions to assist your organization.

What We’ve Done

As we say in Texas, "This ain't our first rodeo." Take a look at a sampling of some of our masterpieces, from logo design and brochure creation to webpage design and online community development.