How to Center a ul or ol List in CSS

text-align: center centers the text inside a ul or ol. To center the list as a group, including its bullets or numbers, limit the list box’s width and apply margin-inline: auto. Use text-align: start to keep the item text aligned at the start of the box.

Center the text inside a list

Use text-align: center when the list should keep its normal width and only the item text should move. With the default list-style-position: outside, bullets and numbers stay outside the item’s content box at the start of the line. For short, single-line items, try inside to include the marker on the same line. On a narrow screen, check long items: their next line can start beneath the marker.

Text alignment rules

Center the entire list box

In normal block layout, an auto-width list fills the available width of its parent. margin-inline: auto distributes the remaining space only when the box is narrower than its parent. inline-size: min(100%, 19rem) caps the width at 19rem and uses the available width in a narrower container. For a list that fits its content, combine inline-size: fit-content with max-inline-size: 100%. In horizontal writing, inline size means width.

Margins in the inline direction

How fit-content sizes a box

Compare the three layouts in one example

Save the two snippets in the same folder as index.html and lists.css, then open index.html in a browser. The first box fills its parent and centers only the text. The second is a numbered list with a width limit. The third is a bulleted list that shrinks to fit its items. The second and third boxes have equal space on both sides.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Centered lists</title>
  <link rel="stylesheet" href="lists.css">
</head>
<body>
<main class="demo">
  <h1>Centered lists</h1>

  <h2>Centered text only</h2>
  <ul class="text-center">
    <li>Check the material</li>
    <li>Save the file</li>
  </ul>

  <h2>Width-limited list</h2>
  <ol class="fixed-center">
    <li>Save the file</li>
    <li>Open the result in your browser</li>
  </ol>

  <h2>Content-sized list</h2>
  <ul class="fit-center">
    <li>Write a draft</li>
    <li>Check that a longer description is easy to read</li>
  </ul>
</main>
</body>
</html>
body {
  margin: 1rem;
  font: 1rem/1.55 system-ui, sans-serif;
}

.demo {
  max-inline-size: 42rem;
  margin-inline: auto;
}

.demo ul,
.demo ol {
  box-sizing: border-box;
  margin-block: 0 1.5rem;
  margin-inline: 0;
  padding-block: 0.65rem;
  padding-inline: 2.5rem;
  border: 2px solid #246;
  background: #eef6ff;
  list-style-position: outside;
  overflow-wrap: anywhere;
}

.demo .text-center {
  text-align: center;
}

.demo .fixed-center,
.demo .fit-center {
  margin-inline: auto;
  text-align: start;
}

.demo .fixed-center {
  inline-size: min(100%, 19rem);
}

.demo .fit-center {
  inline-size: fit-content;
  max-inline-size: 100%;
}

Check markers and wrapping on narrow screens

Make the browser window narrower and check that the second and third lists stay within their parent. box-sizing: border-box includes the border and padding in the specified size. overflow-wrap: anywhere lets a long word wrap when necessary. The list’s start padding leaves room for the outside marker. If markers disappear, check for list-style: none and confirm that li still has its default display: list-item.

List marker positioning