I have created a menu using ul
and li
, but it shows me in reverse order. For example:
FAQ PRICING TOUR HOME instead of the expected HOME TOUR PRICING FAQ
.header ul {
}
.header li {
list-style-type: none;
margin-left: 40px;
float: right;
}
<div class="header">
<ul>
<li><a href="">HOME</a></li>
<li><a href="">TOUR</a></li>
<li><a href="">PRICING</a></li>
<li><a href="">FAQ</a></li>
</ul>
</div>
What's wrong in my code?
This is happening because that's how float was designed. It will "float" the elements in the direction specified, in the order specified.
You should be using an unordered list of items ( UL element with LI elements) to be semantically correct about it. This also helps screen readers and other technologies that depend on correct semantics to work.
You should float only the ul
right. The list items should be floated left in the correct (expected) order:
.header ul {
float:right;
}
// expected order. It's the default value if not overriden,
// therefore it is not realy needed
.header li
{
float:left;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With