Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS inline padding behavior

Tags:

css

For some reason padding on an anchor tag overflows out of the parent <li></li>. When adding display:block it no longer overflows. The same happens with margins instead of padding. Why is the padding ignored when sizing <li></li>?

HTML:

<ul>
<li><a href="">Link</a></li>
</ul>

CSS:

ul{list-style:none;text-align:right;}
ul a{padding:3px;}
like image 517
Hawken Avatar asked Jan 17 '26 23:01

Hawken


1 Answers

There shouldn't be an issue with padding-left or padding-right. But vertical padding won't work on inline element like <a />.

like image 132
Stuart Burrows Avatar answered Jan 19 '26 19:01

Stuart Burrows