Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Hide number in ordered list if there is only one element in the list

Say I have a ordered list like this.

<ol>
  <li>a</li>
<ol>

Since this ol only has one item, I want to render it as

a

On the other hand, if there are more than one item in the list like below, I want to render 1., 2.s.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<ol>
  <li>a</li>
  <li>b</li>
<ol>

should be

1. a
2. b

Is there a way to do this in pure CSS?

>Solution :

li:only-of-type { list-style-type: none; }
<h1>List 1</h1>
<ol>
  <li>Coffee</li>
  <li>Tea</li>
</ol>


<h1>List 2</h1>
<ol>
  <li>Coffee</li>
</ol>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading