I have the following HTML code with some internal CSS:
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
li a:hover {
background-color: #111111;
}
<ul>
<li><a class="active" href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
The above code displays a horizontal menu.
As per my knowledge, unless we use display: inline
property we can't display a list horizontally. Then how could it happen in above code where display: inline
property has not been used and still the list is displayed horizontally?
Someone please explain me.
Thanks.