CSS: Removing List Indent without Removing Bullets

Author: MikeW    Date: 2016-05-22 16:24   

Here is the problem I ran into. I want to remove the indent from an unordered list HTML list using CSS. First, let’s start with a list.

Name List

  • George
  • John
  • Thomas
  • James
  • Andrew

So the information I got said to do this:

1ul {padding:0px; list-style-type: none;}

Which results in:

Name List

  • George
  • John
  • Thomas
  • James
  • Andrew

However, this is not what I want. I still want the bullets. How about we change the style to square.

1ul {padding:0px; list-style-type: square;}

Which results in:

Name List

  • George
  • John
  • Thomas
  • James
  • Andrew

Well that is not what I want either. So after some searching around here is the solution:

1ul {padding:2px; list-style-position:inside; list-style-type: square; }

Which results in:

Name List

  • George
  • John
  • Thomas
  • James
  • Andrew

The key is list-style-position:inside; selector is the key, it moves the bullets in line with the text. I added the padding for aesthetics.