CSS fixed width in a span

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

ul li span {
  float: left;
  width: 40px;
}
<ul>
  <li><span></span> The lazy dog.</li>
  <li><span>AND</span> The lazy cat.</li>
  <li><span>OR</span> The active goldfish.</li>
</ul>

Expand snippet

Like Eoin said, you need to put a non-breaking space into your “empty” spans, but you can’t assign a width to an inline element, only padding/margin so you’ll need to make it float so that you can give it a width.

For a jsfiddle example, see http://jsfiddle.net/laurensrietveld/JZ2Lg/

Leave a Comment