Hi,
list-style-type decimal shows lists like this:
1. apple
2. pear
3. whatever
but I dont need the dot so it looks like this:
1 apple
2 pear
3 whatever
is it possible?
Thank you.
Adding the "list-style: none" CSS class to the unordered list (<ul>) or ordered list (<ol>) tag removes any bullet or number.
The list-style-type property in CSS specifies the appearance of the list item marker (such as a disc, character, or custom counter style) if 'list-style-image' has the value 'none'.
In HTML, there are two main types of lists: unordered lists (<ul>) - the list items are marked with bullets. ordered lists (<ol>) - the list items are marked with numbers or letters.
The default list-style-type value for an ordered list is decimal , whereas the default for an unordered list is disc .
Use CSS Counters or CSS Markers. Ordered lists have a default counter named list-item
you don't have to reset or increment, so the following is equivalent when using the default 0+1 ordering (starting at 0 and incrementing by 1)✻
✻ Thanks goes out to fcrozatier for pointing out the default behavior of list-item
of an <ol>
.
html {
font: 300 2ch/1.2 'Segoe UI'
}
/* ::before Solution */
.A {
list-style: none;
margin-left: -1rem;
}
/* The "\a0" is a space */
.A li::before {
content: counter(list-item)"\a0\a0";
}
/* ::marker Solution */
.B li {
list-style: none;
padding: 0;
}
.B li::marker {
content: counter(list-item)"\a0\a0";
}
<ol>
<li>Default style of <ol></li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ol>
<ol class='A'>
<li>Custom style using <code>::before</code> pseudo-element</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ol>
<ol class='B'>
<li>Custom style using <code>::marker</code> pseudo-element</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ol>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With