This seems to valid for display: inline;
and display: inline-block;
too.
This is what I mean:
ul li {
display: block;
/* Or display: inline; */
/* Or display: inline-block; */
}
<ul>
<li>list item1</li>
<li>list item3</li>
<li>list item3</li>
</ul>
And with list style I mean the actual "bullets" or "numbers" (when <ol>
is used)
That's because normally,
display
is set tolist-item
for<li>
elements. See the W3C CSS3 specification: http://www.w3.org/TR/css3-lists/#declaring-a-list-item.Note that you can give arbitrary HTML elements the same behaviour; set
display: list-item
on a<div>
for example.An updated solution is to make use of
:before
andcontent
.See this JSfiddle for a working example. http://jsfiddle.net/t72h3/
Solution for
ul
Solution for
ol
using counter-incrementMartin's answer is true but doesn't provide a solution and Pappy's is only relevant if you want bullets or easily have access to the what the
li
's identifier will be. In my case, I need to have anol
withupper-alpha
so that's not possible.The shortest way around this for us was to put a an inline (
inline
,inline-block
,inline-flex
) property as well asvertical-align: top
on the immediate child of theli
:A way to get the effect would be:
CSS: