How do I center a list in HTML? Attribute Values: left: It sets the text left-align. . How To Center A List In Html Related Questions. So, if you want to make the list horizontal, you have to explicitly change the display type of the list items from block to either inline-block or inline which can be done using the display property. justify-content: space-around; The position tag set to flex enable the elements to be flexible while the justify-content tag tells the browser how to arrange the elements. Edit: There's a lot of (mostly unnecessary) CSS code in there so you'll probably need to tweak a few other things before it looks right, but the floating is what's causing the non-centering at least. Just give the list centered text (e.g. Why is there a voltage on my HDMI and coaxial cables? Modified today. Lets take a look at more implementations. Then set align-items to center to perform centering on the block axis, and justify-content to center to perform centering on the inline axis. But i'm not getting them in a line. Lets kick off by writing a simple unordered list. Horrible! Center an HTML List Step 1) HTML: Wrap the <ul> element inside a container element, like <div>: Example <div class="container"> <ul class="myUL"> <li> Coffee </li> <li> Tea </li> <li> Coca Cola </li> </ul> </div> Step 2) Add CSS: Center-align the <div> element, and change the display of <ul> to inline-block. This page was last modified on Feb 21, 2023 by MDN contributors. The