Reputation: 8408
I'm using an inline list, and I noticed that that the div on the next line won't respect its padding (i.e. it is drawn right through the li elements' border). Is there anything I can do about that?
<html>
<head>
<style type="text/css">
ul {
margin: 0;
padding: 0;
}
li {
display: inline;
list-style-type: none;
padding: 10px;
border: 1px solid gray;
}
div {
border: 1px solid black;
}
</style>
</head>
<body>
<ul>
<li>Hello</li>
<li>World</li>
</ul>
<div>
Hello, World!
</div>
</body>
</html>
Upvotes: 1
Views: 2232
Reputation: 93674
Inline elements are not affected by top and bottom padding (see why).
Instead you can make them inline-block
:
li {
display: inline-block;
zoom: 1; /* for IE */
*display: inline; /* for IE */
}
Upvotes: 2