Reputation: 3461
If i'll put margin-top to the first list item(LI), then margin is outside of ul.
Same thing for last item and margin-bottom. But margin-left/margin right works as expected..
Why is that and is that fixable?
See :Fiddle Link
Cheers
Upvotes: 1
Views: 1079
Reputation: 12002
You have to put
overflow : auto;
in the parent ul.
See Margin-Top push outer div down
Upvotes: 5
Reputation: 21882
There is nothing between a ul tag and an li tag. They essentially follow each other. What you want is padding in the ul, not margin in the li.
Upvotes: 1
Reputation: 197
Your ul contains only one element witch actually has working margin. You should replace this code
<li>
This is a test<br>
This is a test<br>
This is a test<br>
This is a test<br>
</li>
With:
<li>This is a test</li>
<li>This is a test</li>
<li>This is a test</li>
<li>This is a test</li>
Upvotes: 2