how to reduce default gap between bullet and text in <li>
?
- Item 1
- Item 2
- Item 3
I want to reduce gap between bullet an I
how to reduce default gap between bullet and text in <li>
?
I want to reduce gap between bullet an I
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.)
You might try using:
li {list-style-position: inside; }
But I can't remember if that adjusts the space, or changes where the space occurs.
The above doesn't seem to make any substantial difference. There doesn't seem to be any way to decrease the space between the list-style-type
marker and the text, though it can be increased using margin-left
or text-indent
.
Sorry I can't be of more use.
Just out of curiosity, how about 'faking' the bullet with a background image?
ul {list-style-type: none;
margin: 0;
padding: 0;
}
ul li {background: #fff url(path/to/bullet-image.png) 0 50% no-repeat;
margin: 0;
padding: 0 0 0 10px; /* change 10px to whatever you feel best suits you */
}
It might allow for more fine-tuning.
This is one way.
li span {
margin-left: -11px;
}
<ul>
<li><span>1</span></li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
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:-10px;
}
</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>
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:
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).