I have this nested Ul li element
Lists can be nested (list inside list)
The first level of li elements Coffee, Tea and Milk taking default Padding and Margin. How to remove the first level of li elements left margin and padding.
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
2
Answers
If you have some parent for this first
ul
element (for example somediv
), you can use direct child selector>
:but if you have only this structure you posted above, you can use
:not
selector:you can also reset padding and margin for the first
ul
element and in the next CSS rule overwrite it forul
nested inul
:revert
will resetmargin
andpadding
to the previous value, but you can also use just some value, like10px
instead ofrevert
.first-ul{display: inline;}
add this class