I'd like to control how much horizontal space a bullet pushes its <li>
to the right in an <ol>
or <ul>
.
That is, instead of always having
* Some list text goes
here.
I'd like to be able to change that to be
* Some list text goes
here.
or
*Some list text goes
here.
I looked around but could only find instructions for shifting the entire block left or right, for example, http://www.alistapart.com/articles/taminglists/
To summarise the other answers here – if you want finer control over the space between bullets and the text in a
<li>
list item, your options are:(1) Use a background image:
Advantages:
background-position
to position the image pretty much anywhere you want in relation to the text, using pixels, ems or %Disadvantages:
2. Use padding on the
<li>
tagAdvantages:
<li>
, you can add as much extra horizontal space between the bullet and the text as you likeDisadvantages:
(3) Wrap the text in an extra
<span>
elementAdvantages:
padding-top
to the<span>
. Someone else may have a workaround for this, though...)Disadvantages:
Here's hoping for some new list-style features in CSS4, so we can create smarter bullets without resorting to images or exta mark-up :)
You can also use a background image replacement as an alternative, giving you total control over vertical and horizontal positioning.
See the answer to this Question
It seems you can (somewhat) control the spacing using padding on the <li> tag.
The catch is that it doesn't seem to allow you to scrunch it way-snug like your final example.
For that you could try turning off list-style-type and using •
Here is another solution using css counter and pseudo elements. I find it more elegant as it doesn't require use of extra html markup nor css classes :
I use non breakable spaces so that the spacing only affects the first line of my list elements (if the list element is more than one line long). You could use padding here instead.
For list-style-type: inline:
It's almost the same like DSMann8's answer but less css code.
You just need to
Cheers
You can use the
padding-left
attribute on the list items (not on the list itself!).