I'm struggling with centering the alignment of li
elements within a ul
. Below is the excerpt from my code:
ul.nav {
width: 1000px;
margin: 0 auto;
list-style-type: none;
}
.nav li {
float: left;
width: 300px;
}
#government {
clear: left;
}
Despite attempting various solutions like setting text-align: center;
or using margin: 0 auto;
, I haven't been successful. I've spent hours troubleshooting this issue, so any assistance would be greatly appreciated. Check out the screenshot for reference:
https://i.stack.imgur.com/2or4A.png
The goal is to center the li
elements horizontally within the ul
. Since the width is variable and different for each li
, manually setting margins isn't a feasible solution.