Inline <li>
elements are not positioning themselves within their parent div. It is ok when I set overflow:auto
on the parent div but not without it.
Please help me understand it, how they are getting out of their parent.
Here is my code:
body {
margin: 0;
padding: 0;
}
div {
background-color: black;
color: red;
padding-top: 2px;
padding-bottom: 2px;
}
li {
display: inline;
float: right;
}
ul {
list-style-type: none;
}
<h1>BUSINESS NAME</h1>
<div>
<ul>
<li>HOME</li>
<li>SERVICE</li>
<li>ABOUT</li>
<li>CONTACT</li>
</ul>
</div>