Can't get ul to center - Tribute Page project

I have highlighted in pink the part I’m trying to center and I want to make sure the li’s stay left aligned like they are when the ul is centered. Any help is appreciated!

Code pen:


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ken Block Tribute Page</title>
    <link rel="stylesheet" href="styles.css">
    <div id="main">
        <div id="title">
        <h1>Ken Block</h1>
        Co-Founder of DC Shoes, extreme sports athlete, rally driver and hoonigan.

        <div id="img-div">
            <img src="" alt="Ken Block standing next to a Mustang" id="image">
            <p id="img-caption">Ken Block stands next to the "Hoonicorn", a 1965 Ford Mustang with 1,400 horsepower and all wheel drive that will go 0-60 in 1.8 seconds!</p>

        <div id="tribute-info">
            <h2>Here's a list of Ken Block's achievements:</h2>
                <li>Co-Founded Droors Clothing (DC Shoes) in 1993</li>
                <li>Participated in the Gumball 3000 Rally in 2005</li>
                <li>Began his 1st year in Rally racing and won Rookie of the Year</li>
                <li>Signed a sponsorship deal with Subaru in 2006</li>
                <li>Took home bronze in the 1st ever X-Games rally event</li>
                <li>Took home a silver medal in X-Games XIII rally event</li>
                <li>Appeared in a segment of the car show "Top Gear"</li>
                <li>Filmed the infamous "Gymkhana 2" infomercial with 52 million views</li>
                <li>Co-founded Gymkhana Grid, a gymkhana race held annually around the world</li>
                <li>Founded Hoonigan Racing Division in 2010</li>
                <li>Signed a sponsorship deal with Ford in 2010</li>
                <li>Won the Rally in the 100 Acre Wood for the 5th consecutive time</li>
                <li>Holds the world record for the world's fastest snowcat</li>
                <li>Founded the "Hoonigan" YouTube channel with 940 million views</li>
                <li>Appeared in three installments of the "Dirt" racing video games</li>
                <li>Appears in the 2015 "Need for Speed" video game</li>
                <li>Signs a deal with Audi in 2021 to help develop electric cars</li>
            <q>In life—from the simplest thing to the biggest thing—I want to be proud of what it is and stake my claim: 'That's mine and that's how I do it.'

                --Ken Block

                If you have time, you should read more about this absolute mad lad on his <a id="tribute-link" href="" target="_blank">Wikipedia entry.</a>

    <script src=""></script>


#main {
    background-color: #d3d3d3;
    border-radius: 5px;
    font-family: 'Tahoma', sans-serif;
    margin-top: 1.7em;
    margin-bottom: 1.7em;

#title {
    text-align: center;
    padding-top: 1.5em;
    font-size: 1.2em;

#title p {
    font-size: 0.8em;
    color: rgb(53, 53, 53)

#img-div {
    background-color: black;
    margin: 1em;

#image {
    height: auto;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    display: block;
    padding-top: 1.1em;

#img-caption {
    color: #95D600;
    text-align: center;
    padding-bottom: 1.1em;

#tribute-info {
    text-align: center;

h2 {
    padding-top: 1em;
    padding-bottom: 1em;

ul {
    display: inline-block;
    background-color: pink;

li {
    text-align: left;

Hello @troyb16,

I tested your code on my side. Let me guide you, but know that many solution are possible not only that one.

First, I advice you to not use the value inline-block for the display property. I don’t see the need to use it here. Second, if you remove this property, you will se that the background color of your list takes all the width, that’s why you can also have troubles to position it at the center. You can decide to give your list a special width size. For now, the CSS code can look like:

ul {
  width: 50%; /* You can test other size, other units */

Now you want to center it. Easy way is to use the property margin:

ul {
  width: 50%;
  margin: auto; /* This property and value will center your list */

And here you will obtain something like (I left the background-color property):

This way is an easy way to do. But you can do others :wink:

Thank you for the response LucLH!

While what you have done is very close but it is not quite as I would like it, I would also like the list to be centered with the above H2. If you can help me do that it would be greatly appreciated!

Thank you!

I am not sure I understand perfectly what you need, but let me show you what I understood from your need.

Are you looking for this:

If it is this, you just need to play with the size. Also add a little property to align the text on justify and here we are:

ul {
  width: 30%; /* I just put a lower size to make it well centered with your title */
  margin: auto;
  padding-bottom: 10px;

li {
  text-align: justify; 
1 Like

Yes that is what I am looking for! Thank you so much for your help! :smiley:

1 Like

No problem, happy to help you! I improved the code a little for that it look more centered, you just need to use the property padding to have these result because an ul element always has an internal marge.


ul {
  width: 30%;
  margin: auto;
  padding-bottom: 10px;
  padding-left: 7px;

li {
  text-align: justify;
1 Like

Perfect that looks even better! Once again I appreciate you taking the time to help me, I was stuck for about an hour so this helps a lot, thank you! I hope you have a great day!

1 Like

You are welcome, happy to bring some help! Good luck for the projects and don’t hesitate to ask the community if you need. Have a great day mate :wink:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.