Just give the list centered text (e.g. UL. nav {text-align: center. }) and the list items inline-block (e.g. UL. nav LI {display: inline-block. }). If you want to do it with margin for whatever reason, look into width: fit-content. .