To horizontally center a block element (like <div>), use margin: auto; Setting the width of the element will prevent it from stretching out to the edges of its container. CSS Centering (Text and Images) with Angular 11 Example For this type of menu, you might wanna just consider ditching the unordered list and going with a series of anchor links. Now, add the style to the div class and use the text-align property with center as its value. Sign Up to see how much you could remove. Centering List Items Horizontally | Yet Another Summer Rain - liaohuqiu Ive been using the following code as a standard for my nav, and its worked famously: