| You are here: | About>Computing & Technology>Web Design / HTML> CSS> CSS and Bulleted Lists - Using CSS to Improve Unordered Lists |
![]() | Web Design / HTML |
More Help with Lists and CSSCSS and Bulleted ListsUsing CSS to Improve Unordered ListsUnordered lists are all over the Web. They can be used for almost anything you can think of and they make it easier for people to read your Web pages. But styling them can be challenging, especially if you need them to be in a specific position inside a box. A Standard Unordered ListFor the purposes of this article, we'll be working with a standard unordered list of links. Except for the last example, the list elements don't have to be links, but that is really common. The HTML looks like this: <ul> Unordered lists are fairly boring. The list items are displayed one after the other, each following a bullet icon. And the first thing you may notice if you're trying to get your Web page to look identical in IE and Firefox is that the bullets don't look the same. The IE bullet has some anti-aliasing on it to make it look rounder, whieh the Firefox bullet is only two colors (black and white) so it looks more like a small diamond if you look at it closely. Change the Bullet By Using an Image InsteadThe simplest way to make the bullets identical is to tell the browsers to use an image instead of their default bullets. To do this, you use the list-style-image CSS property. I took screenshots of the bullets in Firefox and IE and created image files from them. You may download them if you'd like: Use this CSS to set up your unordered list with these images for bullets: #ie li { But changing the bullet can be tricky too. The icons may be displayed too far above or below the line and you can end up with strange layouts in different browsers. Use a Background ImageA more advanced way of creating a bulleted list with icons for bullets is to use a background-image and set the list-style to none. This is a bit trickier because you have to set styling on both the UL element and the LI. Otherwise, your bullet will end up being behind the text rather than beside it. First, turn off the bullets and set up the image as your background. Make sure to align it to the center and left and set it to no-repeat: li { Then, set the left padding so that your text doesn't sit on top of your bullet: ... Finally, adjust the margin and padding on the ul itself so that the list displays where you want it to: ul { But There's Lots More You Can Do with Lists and CSSMore Help with Lists and CSS |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


