302

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/

1

30 Answers 30

229

Put its content in a span which is relatively positioned, then you can control the space by the left property of the span.

li span {
  position: relative;
  left: -10px;
}
<ul>
  <li><span>item 1</span></li>
  <li><span>item 2</span></li>
  <li><span>item 3</span></li>
</ul>

Sign up to request clarification or add additional context in comments.

6 Comments

+1 for actually answering the guy's question ;) (though the span should ideally in real life have a class anyway for good practice futureproofing as well as semantics: if in future any javascript or new features development etc had a good reason to add extra spans to your content, things could get messy)
in firefox there is not display properly text is overlapping the bullets using this trick
@ingyhere I doub't this is true, since I cannot find anything that proves this claim. Can you provide any sources?
@Wolle Hmmm. It's an old comment, and I'm not sure of the concern -- If it's as to whether <SPAN> can utilize id or class tags, take a look at W3C. If the question is whether it can convey semantic meaning, see this answer. Technically, the <SPAN> tag is a non-semantic inline element by itself, but in some way that affords more flexibility in its re-use. Nowadays, I believe one can use the inline-block descriptor to allow a lot greater range of formatting options.
The solution should involve removing the default value rather than adding a counterpart negative value. In addition, this doesn't answer the question on how much of a negative value you need to completely negate the default value. Guess work doesn't have a place in a modern web design.
159

This is an outdated answer written in 2012

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) Remove the default marker and fake it with a background image:

<style type="text/css">
li {
    list-style-type:none;
    background-image:url(bullet.png);
}
</style>

<ul>
    <li>Some text</li>
</ul>

Advantages:

  • You can use any image you want for the bullet
  • You can use CSS background-position to position the image pretty much anywhere you want in relation to the text, using pixels, ems or %

Disadvantages:

  • Adds an extra (albeit small) image file to your page, increasing the page weight
  • If a user increases the text size on their browser, the bullet will stay at the original size. It'll also likely get further out of position as the text size increases
  • If you're developing a 'responsive' layout using only percentages for widths, it could be difficult to get the bullet exactly where you want it over a range of screen widths

2. Add more space by adding padding on the <li> tag (assumes list-style-position: outside, doesn't remove default spacing)

<style type="text/css">
ul {padding-left:1em}
li {padding-left:1em}
</style>

<ul>
    <li>Some text</li>
</ul>

Advantages:

  • No image = 1 less file to download
  • By adjusting the padding on the <li>, you can add as much extra horizontal space between the bullet and the text as you like
  • If the user increases the text size, the spacing and bullet size should scale proportionally

Disadvantages:

  • Can't move the bullet any closer to the text than the browser default
  • Limited to shapes and sizes of CSS's built-in bullet types
  • Bullet must be same colour as the text
  • No control over vertical positioning of the bullet

3. Extend the list item beyond its box using a negative margin

<style type="text/css">
li {
    padding-left:1em;
    color:#f00; /* red bullet */
}
li span {
    display:block;
    margin-left:-0.5em;
    color:#000; /* black text */
}
</style>

<ul>
    <li><span>Some text</span></li>
</ul>

Advantages:

  • No image = 1 less file to download
  • You get more control over the position of the bullet than with option (2) – you can move it closer to the text (although despite my best efforts it seems you can't alter the vertical position by adding padding-top to the <span>. Someone else may have a workaround for this, though...)
  • The bullet can be a different colour to the text
  • If the user increases their text size, the bullet should scale in proportion (providing you set the padding & margin in ems not px)

Disadvantages:

  • Requires an extra unsemantic element (this will probably lose you more friends on SO than it will in real life ;) but it's annoying for those who like their code to be as lean and efficient as possible, and it violates the separation of presentation and content that HTML / CSS is supposed to offer)
  • No control over the size and shape of the bullet

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 :)

5 Comments

Great answer. For #2 to work, be sure you maintain your list-style-position to outside.
The span element is the fix for me. I +1'ed this answer only because I preferred negative margin to negative absolute positioning - for no good reason.
If you have text that wraps lines I found that I had to add display: block; to the span element for so the wrapped text would line up as well ( I also ended up using anchor tags instead of spans )
Using background images for anything that is not just that is almost always a very bad idea. They can't be saved, are not printed and not mentioned by screen readers. Using <span> ist most elegant way to solve this. paddings will not work as they also change position of the bullets.
I would NEVER use background image for this. You can always use the :before element with the content: "•"; then, you use padding and absolute position on that before element to control it.
63

This is an outdated answer written in 2013

This should do it. Be sure to set your bullets to the outside. you can also use CSS pseudo elements if you can drop them in IE7 downward. I don't really recommend using pseudo elements for this kinda thing but it does work to control distance.

ul {
  list-style-type: circle;
  list-style-position: outside;
  width: 100px;
}

li {
  padding-left: 40px;
}

.pseudo,
.pseudo ul {
  list-style: none;
}

.pseudo li {
  position: relative;
}

/* use ISO 10646 for content http://la.remifa.so/unicode/named-entities.html */
.pseudo li:before {
  content: '\2192';
  position: absolute;
  left: 0;
}
<ul>
  <li>Any Browser really</li>
  <li>List item
    <ul>
      <li>List item</li>
      <li>List item</li>
    </ul>
  </li>
</ul>

<ul class="pseudo">
  <li>IE8+ only</li>
  <li>List item
    <ul>
      <li>List item with two lines of text for the example.</li>
      <li>List item</li>
    </ul>
  </li>
</ul>

9 Comments

I can't believe this answer isn't accepted. It's 100% CSS, it doesn't add any superfluous <span> element, and it made me finally understand why there is a inside/outside option ! (and it's the accepted answer of the duplicate question mentioned...)
Using list-style-position: outside and padding on the LI elements allows you to increase the distance between the bullet points but it still doesn't work the other way around beyond a browser specified offset. See this JS Bin.
Addendum: In modern browsers (IE9+, FF, Chrome, etc.), use a negative text-indent on the <UL> or <LI> to negate the browser enforced distance between bullet point and <LI> content. That is, increase padding-left as shown above to increase the distance and reduce text-indent to reduce the distance between the bullet point and the content as desired.
Alas, for all of the above mentioned desktop browsers, if the contents of an <LI> wraps into a second line, such subsequent lines end up being re-indented based on the margin/padding/indent that we managed to undo for the first line via text-indent. Sigh
another option is to use the :before pseudo elements and set the content to whatever you like. from there position the pseudo elements as desired.
34

There seems to be a much cleaner solution if you only want to reduce the spacing between the bullet point and the text:

li:before {
    content: "";
    margin-left: -0.5rem;
}

6 Comments

This should be the accepted answer; I wasted a lot of time trying to adapt the hacks above.
This doesn't work well with multi-line bullets, where the original spacing takes effect after the first line.
The negative spacing approach should never be an acceptable solution.
@Vanuan You've left basically this same comment a lot of times — can you please explain why negative spacing is so universally A Bad Idea? Maybe include it as part of your current-summary answer, which I don't believe mentions negative spacing at the moment?
@igorsantos07 My primary concern here is that these hardcoded values are arbitrary. Yes, if you only target Chromium/Webkit it's ok. But there's no guarantee the margin of 1rem be enough to negate. CSS standard doesn't specify the default browser behavior of lists. So you're just eyeballing it.
24

You can use the padding-left attribute on the list items (not on the list itself!).

4 Comments

Please note this only works if the list-style-position is set to the default outside.
This should be the accepted answer, at least for normal usage. It avoids using a <span> element just for design purpose.
@eukras Unfortunately, it shouldn't, as it only allows more space.
Firstly, it doesn't remove the default spacing, only increases it. Secondly, this only works for the outside list marker position.
20

For list-style-type: inline:

It's almost the same like DSMann8's answer but less css code.

You just need to

<style>
    li:before {
        content: "";
        padding-left: 10px;
    }
</style>

<ul>
    <li>Some content</li>
</ul>

Cheers

3 Comments

This works for list-style-position: inside too, which is great!
If you want the spacing to be smaller you can use margin-left: -10px property.
This is a good solution to add more spacing between the list item and the marker. Sadly, it lacks the other part: removing the default spacing.
17

Old question, but the :before pseudo element works well here.

<style>
    li:before {
        content: "";
        display: inline-block;
        height: 1rem;  // or px or em or whatever
        width: .5rem;  // or whatever space you want
    }
</style>

It works really well and doesn't require many extra rules or html.

<ul>
    <li>Some content</li>
    <li>Some other content</li>
</ul>

Cheers!

4 Comments

Nice & simple answer. I would add that setting margin-left: -5px (or whatever value) will decrease the space between the bullet and the <li> element
Note: This does not support hanging indents
Awesome answer, this worked perfectly with the most minimal amount of work! Thanks!
This increases the gap between the marker and the list text. Still lacks the solution to remove the default spacing.
12

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 :

    ol,
    ul {
        list-style-position: inside;
    }
    
    li {
        list-style-type: none;
    }
    
    ol {
        counter-reset: ol; //reset the counter for every new ol
    }
    
    ul li:before {
            content: '\2022 \00a0 \00a0 \00a0'; //bullet unicode followed by 3 non breakable spaces
    }
    
    ol li:before {
            counter-increment: ol;
            content: counter(ol) '.\00a0 \00a0 \00a0'; //css counter followed by a dot and 3 non breakable spaces
    }

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.

1 Comment

This is a fine solution. The only problem is non breaking spacing. It's far more reliable to use margin-right as it gets you predictable spacing, not depending on width of the space in a given font. Additionally, you could just use list-style-type: '•'
9

The following solution works well when you want to move the text closer to the bullet and even if you have multiple lines of text.

margin-right allows you to move the text closer to the bullet

text-indent ensures that multiple lines of text still line up correctly

li:before {
  content: "";
  margin-right: -5px; /* Adjust this to move text closer to the bullet */
}

li {
  text-indent: 5px; /* Aligns second line of text */
}
<ul>
  <li> Item 1 ... </li>
  <li> Item 2 ... this item has tons and tons of text that causes a second line! Notice how even the second line is lined up with the first!</li>
  <li> Item 3 ... </li>
</ul>

enter image description here

1 Comment

Negative values is never a fair game with rare exceptions.
7

Using text-indent on li works best.

text-indent: -x px; will move the bullet closer to li and vice-versa.

Using relative on span the negative left might not work properly with older versions for IE. P.S- avoid giving positions as much as you can.

2 Comments

This behaves strange on Chrome. Snaps to little space at -5px;
Negative values are a shit solution
7

Nobody mentioned ::marker property

It allows to set the space smaller than browser default.

ul > li::marker {
  content: '•'; /* as a side effect sets the space to zero */
  font: 1.2em/1 sans-serif; /* adjust the bullet size */
}
ul > li {
  padding-left: .2em; /* have full control over the bullet space */
}
<ul>
  <li>one
  <li>two
  <li>three
</ul>

As @Vanuan mentions in the comment, this can not be used with list-style-position: inside as the MDN states:

inside: The ::marker is the first element among the list item's contents

So it is displayed inline and display property can not be set on ::marker, prohibiting to set padding on it. In that case white-space: pre can be set to the ::marker and spaces can be added to its content attribute.

11 Comments

Sadly, it supports a limited number of properties, and margin/padding is not a one of them. Might as well, just use ::before and ditch the <li>
Also, this answer doesn't mention the inside marker position
@Vanuan The link mentions all the styles that can be attached to ::marker pseudoelement and the padding is set to li, not its ::marker. It has nothing to do with list-style-position. Please clarify your issue.
When you set the list-style-position to inside, your solution doesn't work.
@Vanuan Then you should provide some answer which contains the missing parts and the issues, I'd gladly support it.
5

Old question but still relevant. I recommend using negative text-indent. list-style-position must be outside.

Pros:

  • Bullet is properly automatically positioned
  • Change font size does not break the bullet position
  • No extra elements ( no ::pseudo-elements too )
  • Works for both RTL and LTR without change in CSS.

Cons:

  • try
  • to
  • find
  • one :)

3 Comments

I tried using this method but the indent doesn't work for me if there are line breaks. Text indent will only indent the first line.
Trying this in Chrome just now with list style type outside (I also tried inside) just moves the entire li left or right and doesn't move the text closer or farther from the bullet itself. I tried putting the indent on the ul and on the li and neither had the desired effect.
Limited applicability in addition to shitty negative value solution
5

You can use CSS property padding-inline-start:

li { 
    padding-inline-start: 1em;
}

2 Comments

This solution deserves more credit. Especially now that IE11 is being discontinued.
Again, just adds more space, doesn't solve the default gap problem.
5

Here's an excellent and fresh (2024) article I've found that answers this question exhaustively:

Here are the key details:

  1. Built-in markers (e.g., disc):

    • There's a minimum gap that browsers apply by default.
    • This minimum gap cannot be decreased using standard CSS properties.
    • Oddly, there's no gap for decimal markers, but browser implementation varies.
  2. ::marker pseudo-element:

    • ::marker supports only a small set of CSS properties. You can't set a margin or padding on it.
    • There's an open issue on W3C GitHub to add margin support.
    • Its main use is to replace content with a custom symbol or image, or you can use the list-style-type property for this.
  3. Using custom markers:

    • Custom markers don't set the minimum gap, but you still can't control the marker's margin directly.
    • You have to set padding-left (or margin-left) on the li element:
      li {
        padding-left: 1em; /* Adjust as needed */
      }
      
    • This only works for the outside marker position. See below.
    • Custom string markers have a smaller default size than built-in markers. You'd need to change font-* on ::marker to increase their size.
  4. list-style-position:

    • This property has a significant impact on the list box model.
    • With outside (default), the marker is outside the border of the <ul>/ol> element. You can still use margin to bring it inside of the perceived element extents.
    • The inside value affects how padding-left on <li> works:
      ul {
        list-style-position: inside;
      }
      
    • With inside, padding-left on <li> won't influence the gap between it and the marker. You'll have to use ::before to add the margin (or padding):
      li::before {
        content: '';
        display: inline-block;
        margin-left: 1em;
      }
      

Run this snippet to see the examples:

body {
  padding: 1em;
}

ul, ol, li {
  margin: 0;
  padding: 0;
}

ul, ol {
  border: 1px solid black;
}


        .increased-gap li {
            padding-left: 1em;
        }
        .minimal-gap {
            list-style-type: "•";
            list-style-position: outside;
        }
        .minimal-gap-number > li::marker {
           content: '[' counter(list-item) ']';
        }

        .gap-inside {
          list-style-position: inside;
            list-style-type: "•";
        }
        .gap-inside-increased {
          list-style-position: inside;
            list-style-type: "•";
        }
        .gap-inside-increased > li::before {
          content: '';
          margin-left: 1em;
        }
    <h2>List Gap Examples</h2>

    <!-- Default gap (built-in marker) -->
    <h3>1. Default gap</h3>
    <ul>
        <li>Some list text goes here.</li>
        <li>Another list item for comparison.</li>
    </ul>

    <!-- Increased gap -->
    <h3>2. Increased gap (still has the default gap)</h3>
    <ul class="increased-gap">
        <li>Some list text goes here.</li>
        <li>Another list item for comparison.</li>
    </ul>

    <!-- Minimal gap (using custom marker) -->
    <h3>3. Minimal gap (custom marker).</h3>
    <ul class="minimal-gap">
        <li>Some list text goes here.</li>
        <li>Another list item for comparison.</li>
    </ul>

    <h3>4. Minimal gap with numbering using ::marker</h3>
    <ol class="minimal-gap-number">
        <li>Some list text goes here.</li>
        <li>Another list item for comparison.</li>
    </ol>

    <h3>5. Moving the marker inside the list</h3>
    <ul class="gap-inside">
        <li>Some list text goes here.</li>
        <li>Another list item for comparison.</li>
    </ul>

    <h3>6. Increased gap inside the list</h3>
    <ul class="gap-inside-increased">
        <li>Some list text goes here.</li>
        <li>Another list item for comparison.</li>
    </ul>

2 Comments

Nice summary after the years.
This is a solution specifically about the gap. Still missing one crucial feature which is @counter-style CSS at-rule. But it can only be used to extend existing list of predefined markers like disc, circle, square, it doesn't allow you to override them which kind of defeats the purpose. content: "symbol" is much simpler and more effective approach.
4

It seems you can (somewhat) control the spacing using padding on the <li> tag.

<style type="text/css">
    li { padding-left: 10px; }
</style>

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 &bull;

<ul style="list-style-type: none;">
    <li>&bull;Some list text goes here.</li>
</ul>

1 Comment

A good start. The only problem is using HTML escape sequence for bullet point doesn't allow you to add spacing between the text and the marker.
4

An unordered list starts with the ul tag. Each list item starts with the The list items will be marked with bullets (small black circles) by default:

    <!DOCTYPE html>
    <html>
       <body>
          <h2>Normal List </h2>
          <ul>
             <li>Coffee</li>
             <li>Tea</li>
             <li>Milk</li>
          </ul>
       </body>
    </html>

Output:

<!DOCTYPE html>
<html>
<body>

<h2>Normal List </h2>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

</body>
</html>

The text-indent property specifies the indentation of the first line in a text-block.
Note: Negative values are allowed. The first line will be indented to the left if the value is negative.

<ul style='text-indent: -7px;'>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

3 Comments

Thanks for the answer, please try to annotate your solutions though, for ease of others' understanding.
Changing the text indent on the UL seemed to just move the entire LI left or right, bullet included. It did not appear to make the text get closer or farther from the bullet itself, using inside or outside on the type. Maybe I'm doing something wrong, but I don't see how this works to answer the question.
Negative values are a shit solution
3

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

Comments

3

You can just give a padding-left to your <li> element.

1 Comment

Padding-left can increase the space between bullet and text, but not reduce it (in FireFox anyway)
2

If you'd prefer not to add additional markup e.g. <span>, you could use:

  1. list-style-position: inside; to move the list-style closer to your text from the left
  2. And if you still need to pull the list items closer you can use the ::before selector on the li element to move the text toward the bullet.
    ul {
        list-style-type: disc;
        list-style-position: inside;
        padding-left: 16px; /* or margin */
    }

    li::before {
        content: '';
        margin-left: -8px;
    }
  • List item text
  • List item text
  • List item text
  • List item text

1 Comment

The default list marker doesn't allow you to reduce the gap between the list item and the marker. Negative value for margin does not remove the gap, only offsets it.
2

I know I'm late, but for anyone finding this question who needs to use list-style-position: inside and want to control the spacing between the ::marker without using pseudo-elements like ::before or ::after, there's a simple solution. I encountered the same issue and found that applying letter-spacing to the ::marker does the trick. While I'm not certain if this is a good practice, it worked perfectly for my needs

1 Comment

Quick Note: there will be a letterspacing between the letters of the ::marker too! which is probably not a good thing, so i just added a ::before where i implemented the counting etc
1

More info w3schools ul { list-style: none; }

ul li::before { content: "\2022"; color: black; display: inline-block; width: 8px;}

Comments

1

It's interesting that most of us reach for margin, padding and/or position properties when faced with a problem like this. I know I did in the past. What if we're looking at it all wrong?

Before I provide a different solution, let's try and understand browser implementations a bit better. If we look at the user agent stylesheet for lists in WebKit, here's what we find:

ul, menu, dir {
    //...
    margin-inline-start: 0;
    margin-inline-end: 0;
    padding-inline-start: 40px;
}

ol {
    //...
    margin-inline-start: 0;
    margin-inline-end: 0;
    padding-inline-start: 40px;
}
li {
    display: list-item;
    text-align: match-parent;
}

The other browsers are similar. The list indent is provided by padding on the ul and ol, not the li. Also worth noting, there's no negative positioning, margin, or indent anywhere to be found. So what is creating that gap between the bullet and the text?

The answer only becomes clear when we try changing the bullet character itself. I'll use the list-style-type property to do this, but instead of giving it a standard value like disc (the definition of which is up to the browser, being a little vague in the specs), I'll give it a quoted string value:

ul {
   list-style-type: "•";
}
<ul>
   <li>Oh dear</li>
   <li>what happened</li>
   <li>to the bullet spacing?</li>
</ul>

We can reintroduce the spacing by adding a standard space character after the bullet"

ul.custom-bulleted {
   list-style-type: "• ";
}
<ul class="custom-bulleted">
   <li>Ah, that's better.</li>
   <li>I've never cared for sticky bullets.</li>
</ul>

<ul>
   <li>I'm an unstyled list.</li>
   <li>I never have that problem!</li>
</ul>

I can only assume that this is akin to what the browsers are doing internally—inserting whitespace after the bullet and essentially floating the whole thing to the immediate left of each li. In fact the specs pretty much confirm this by comparing the default internal implementation to the @counter-style at-rule which allows us to define our own list types:

The following stylesheet fragment provides the normative definition of these predefined counter styles:

@counter-style disc {
  system: cyclic;
  symbols: \2022;
  /* • */
  suffix: " ";
}

The whitespace is right there in the suffix.

There's one unanswered question though… Why does the unstyled list look different to the custom-bulleted class in my example? Again, it seems to come down to each browser's different internal implementation. If you compare them in different browsers, even the custom bullets vary between browsers. What I have found though, is that you can standardise the appearance of a string list-style-type simply by declaring a font-family on li::marker, a feature that wasn't available to us when this question was originally asked.

So, coming back to the original question, if we want to control the space between the bullet and the li, we can do so by changing the width of the whitespace character, or by adding multiple whitespace characters, using a string-based list-style-type, which has wide browser support. Alternatively, we could define a custom list style with @counter-style, but that is not currently supported by Safari.

Unicode offers us a wide range of whitespace characters to choose from. Here's a list that uses an Em Space (U+2003):

ul {
   list-style-type: "•\002003";
}
<ul>
   <li>I like big gaps and I cannot lie</li>
   <li>You other brothers can't deny</li>
</ul>

I know this approach is not the first one that springs to mind. We've been so used to aligning things with margins, padding and indents that we tend to reach for those tools every time. But in many ways, the browser's way makes sense. What could be simpler than indenting the whole list with a single padding declaration on the ul, and letting the bullet take care of itself? (Maybe one day, the li::marker pseudo-element will support padding, for those who reckon they need even more fine-grained control. I won't be holding my breath though.)

7 Comments

This is not how the default marker spacing is added in the browsers. In Chrome, for example, the default spacing is added by hardcoding margin-right: xx to the ::marker pseudo-element for corresponding predefined marker. Sadly, ::marker doesn't support margin yet: github.com/w3c/csswg-drafts/issues/4571
@Vanuan, what makes you conclude that the default spacing is provided by margin-right? In the link you provided, the last response by Loirooriol says: 'Currently there is no margin, the gap is caused by a space character in the suffix. Once margin is supported, the margin will just add extra separation in addition to the space.'
suffix is only used for counter markers. The unordered list standard markers don't use suffix, they use margin. The spec doesn't define this, it's implementation detail in Chrome. In other browsers it can be implemented differently.
if you open unordered list with a disc marker in Inspector in Chrome you'll see that the ::marker element is an inline element with margin-left set to 16px (1rem). And the content of the marker doesn't have any spaces. I haven't checked other browsers, but I suspect they have similar implementation
I've just rechecked, and the gap is not always displayed as a right margin of the marker. More often it is just not attributed to any element. You have a marker and you have text. Almost like there's some hidden pseudo-element after ::marker.
1

A solution to control the space between numeral and text with respect to widest marking.

Tip: edit the last 'text-align' to get 'inside or 'outside effect. You can remove 'upper-roman' for standard numeral.

ol {
  counter-reset: n;
  display: table-row;
  text-align: left;
}
li {
  counter-increment: n;
  display: table-row;
  text-align: left;
}
li::before {
  content: counter(n, upper-roman) ".";
  display: table-cell;
  padding-right: 1rem;
  text-align: left;
}
<ol>
  <li>test1</li>
  <li>test2</li>
  <li>test3</li>
</ol>

1 Comment

The ol should probably be display: table not display: table-row — otherwise you cannot apply margins to it.
1

I don't like either of the solutions presented above. My solution:

li:firts-letter { margin-left: -0.25rem; }

Margin value will vary for different fonts

1 Comment

Simple - I like that! But make it li:first-letter { margin-left: -0.25rem; } and adjust the 0.25rem to taste,
0

You can use ul li:before and a background image, and assign position: relative and position:absolute to the li and li:before, respectively. This way you can create an image and position it wherever you want relative to the li.

Comments

0
ul
{
list-style-position:inside;
} 

Definition and Usage

The list-style-position property specifies if the list-item markers should appear inside or outside the content flow.

Source: http://www.w3schools.com/cssref/pr_list-style-position.asp

1 Comment

This does not answer the question. It asks the method for controlling the size of the indentation.
0

Use padding-left:1em; text-indent:-1em for the <li> tag.
Then, list-style-position: inside for the <ul> tag.

<ul style='list-style-position: inside;'>
  <li style='padding-left: 1em; text-indent: -1em;'>Item 1</li>
</ul>

Comments

0

If your list-style is inside then you could remove the bullet and create your own ... e.g. (in scss!)

            li {
                list-style: none;
                &:before {
                    content: '- ';
                }
            }

And if you list style is outside then you could do something like this:

            li { 
                padding-left: 10px;
                list-style: none;
                &:before {
                    content: '* '; /* use any character you fancy~! */
                    position: absolute;
                    margin-left: -10px;
                }
            }

Comments

0

I'm 99.9999% sure no one cares because this question has been asked 12 years ago, but I needed to solve this just now and here's what I found:

A trailing space is treated as part of the escape, so use 2 spaces if you actually want to follow the escaped character with a space.

And, indeed, it works!

ul.asterisks {
  list-style-type: '\2731\ ';
}

Source: Using character escapes in markup and CSS

P.S. Maybe this is because I've been at it for so long that I'm losing my mind? Inserting spaces works in the browser's dev view. To actually get the spaces to take I had to...escape...the spaces?? (See above.) Madness. (BTW, Why are all these pages from 2010? What happened in 2010? Wait a minute...12 years ago was...2010. :fear:)

Source: CSS character escape sequences

1 Comment

Stackoverflow blew up in 2010
-1

I found another "solution" but it might be to hackish. But liked to share anyway because it might be usefull for someone. For me it was perfect because i can use the responsiveness of the bullet when the font size changes. Also the bullet is always inline because of position inside. And i had to work with borders between the list. Only downfall it uses empty list-items.

ul {
    border-top: 2px solid #000;
    padding: 0;
    list-style-position: inside;

    li {

        &:nth-of-type(odd) {
            padding-top: 10px;
            position: absolute;
            pointer-events: none;
        }

        &:nth-of-type(even) {
            position: relative;
            list-style-type: none;
            padding-top: 10px;
            padding-bottom: 14px;
            padding-left: 24px;

            &::after {
                content: '';
                display: block;
                border-bottom: 2px solid #000;
                position: absolute;
                left: 0;
                bottom: 0;
                width: 100%;
            }
        }
    }
}
<ul>
    <li></li>
    <li>
        List item one (this will align perfect on multiple lines) list item one list item one list item one list item one
    </li>
    <li></li>
    <li>
        List item two
    </li>
    <li></li>
    <li>
        List item three
    </li>
</ul>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.