cssmarkdownhtml-lists

how to remove the underline of second level nested ul in markdown?


Cannot remove the underline from the second level of a nested ul in Markdown.

Code

Markdown

* list item (first ul first li)
  * list item (second ul first li)
  * list item (second ul second li)
  * list item (second ul third li)
* list item (first ul second li)
  * list item (second ul first li)
  * list item (second ul second li)

CSS

ul { font-variant: small-caps; text-decoration: underline; }
ul ul { font-variant: normal; text-decoration: none; }

Summary

I discovered this issue in vscode and then went online to test if it was just a bug in vscode or with the extension I was using. I discovered the issue persists online in various markdown sites.

I have used different css rules such as ul ul { text-decoration: unset; } and have used ul ul { text-decoration: none !important; }. None of these seem to work.

Image

vscode screenshot

Questions

  1. Is this just a bug or planned design of markdown behavior?
  2. Is there a fix or workaround for this?

Solution

  • Perhaps this will work:

    ul > li {
        font-variant: small-caps;
        text-decoration: underline;
    }
      
    ul ul > li {
        font-variant: normal;
        text-decoration: none !important;
    }
    <ul>
        <li>Unorderlist1</li>
        <ul>
            <li>List1</li>
            <li>List2</li>
            <li>List3</li>
        </ul>
        <li>Unorderlist2</li>
        <ul>
            <li>Text1</li>
            <li>Text2</li>
            <li>Text3</li>
        </ul>
    </ul>