html horizontal list centered code example
Example 1: horizontal list css
<!DOCTYPE html>
<html>
<head>
<style>
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;
}
</style>
</head>
<body>
<h2>Navigation Menu</h2>
<p>In this example, we use CSS to style the list horizontally, to create a navigation menu:</p>
<ul>
<li><a 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>
</body>
</html>
Example 2: how to align list to the centre in css
<ul class="text-center" style="list-style-position: inside">
<li>Born</li>
</ul>
Example 3: have unordered list horizontal css
#div_top_hypers {
background-color:#eeeeee;
display:inline;
}
#ul_top_hypers li{
display: inline;
}
Example 4: list elements vertically in html
display: inline-block
Example 5: how to align list to the centre in css
<div id="menu-centered">
<ul>
<li><a href="">My first item</a></li>
<li><a href="">My second item</a></li>
<li><a href="">My third item</a></li>
<li><a href="">My fourth item</a></li>
<li><a href="">My fifth item</a></li>
</ul>
</div>