Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reducing the gap between a bullet and text in a list item

Tags:

css

html-lists

How can I reduce default gap between bullet and text in an <li>?

  • Item 1
  • Item 2
  • Item 3

I want to reduce gap between the bullet and "I".

like image 431
Jitendra Vyas Avatar asked Mar 14 '10 03:03

Jitendra Vyas


3 Answers

I'm not sure whether this is the best way to do it, but you could specify a negative text-indent:

li {
    text-indent: -4px;
}

...where your HTML code looks like:

<ul>
    <li>Item 1</li>
    <li>Item 2</li>
</ul>

(Tested in Safari 4.0.4 and Firefox 3.0.11.)

like image 186
Steve Harrison Avatar answered Oct 19 '22 20:10

Steve Harrison


You could achieve this by setting the list-style-type to none, and setting the background-image of a list element to a generic bullet, like so:

ul {
    list-style-type: none;
}

li {
    background-image: url(bullet.jpg);
    background-repeat: no-repeat;
    background-position: 0px 50%;
    padding-left: 7px;
}

The outcome would look a little something like this:

alt text

With this approach, you aren't adding unnecessary span (or other) elements to your lists, which is arguably more practical (for later extendibility and other semantic reasons).

like image 30
gpmcadam Avatar answered Oct 19 '22 21:10

gpmcadam


You could try the following. But it requires you to put a <span> element inside the <li> elements

<html>
<head>
<style type="text/css">
ul.a li span{
position:relative;
left:-0.5em;

}
</style>
</head>

<body>

<ul class="a">
  <li><span>Coffee</span></li>
  <li><span>Tea</span></li>
  <li><span>Coca Cola</span></li>
</ul>
</body>
</html>
like image 24
Jaime Garcia Avatar answered Oct 19 '22 20:10

Jaime Garcia