How can I center
  • into a div?

Since ul and li elements are display: block by default — give them auto margins and a width that is smaller than their container.

ul {
    width: 70%;
    margin: auto;
}

If you’ve changed their display property, or done something that overrides normal alignment rules (such as floating them) then this won’t work.

Leave a Comment