I am trying to create a custom style, and checking it with "HTML5 kitchen sink". The margin between nested <ul> elements confuses me.
When I inspect the elements: a <ul> has a top margin of 16px. A nested <ul> within a <ul> has a top margin of 0px. This leads me to believe that for the user agent there are not static defaults for each element as I used to believe, but a custom style sheet with a bunch of rules (e.g. testing for nested lists).
Question: How does the default user agent style the gap between nested <li> as zero, but between adjacent <li> items in side by side <ul> as NOT zero? Refer to below to make it more clear ("NO GAP BELOW HERE"/"GAP BELOW HERE"):
I created a code pen here: https://codepen.io/run_the_race/pen/JmqEER
body {
background-color: #a3d5d3;
}
<ul>
<li>Unordered List item one
<ul>
<li>Nested list item, NO GAP BELOW HERE
<ul>
<li>Level 3, item one, NO GAP ABOVE HERE</li>
<li>Level 3, item two</li>
<li>Level 3, item three</li>
<li>Level 3, item four</li>
</ul>
</li>
<li>List item two</li>
<li>List item three</li>
<li>List item four</li>
</ul>
</li>
<li>List item two</li>
<li>List item three</li>
<li>List item four, GAP BELOW HERE</li>
</ul>
<ul>
<li>ul + ul: Item 1, GAP ABOVE HERE</li>
<li>ul + ul: Il item 2</li>
<li>ul + ul: Il item 2</li>
</ul>