TExcelTAD
Home › CSS › CSS Lists

CSS Lists

HTML has unordered lists (<ul>) with bullets and ordered lists (<ol>) with numbers. CSS controls the marker type, its position, custom images, and — very often — removes the markers entirely so a list can become a menu.

list-style-type

Value Marker
disc (default for ul) ●
circle ○
square ■
decimal (default for ol) 1. 2. 3.
decimal-leading-zero 01. 02.
lower-alpha / upper-alpha a. b. / A. B.
lower-roman / upper-roman i. ii. / I. II.
none no marker
"→ " (a string) any text you like
html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  body { font-family: system-ui, sans-serif; display: flex; flex-wrap: wrap; gap: 4px 30px; }
  ul, ol { margin: 4px 0; }
  .circle { list-style-type: circle; }
  .square { list-style-type: square; }
  .roman  { list-style-type: upper-roman; }
  .alpha  { list-style-type: lower-alpha; }
  .custom { list-style-type: "👉 "; }
</style>
</head>
<body>
  <ul class="circle"><li>circle</li><li>circle</li></ul>
  <ul class="square"><li>square</li><li>square</li></ul>
  <ol class="roman"><li>upper-roman</li><li>upper-roman</li></ol>
  <ol class="alpha"><li>lower-alpha</li><li>lower-alpha</li></ol>
  <ul class="custom"><li>string marker</li><li>string marker</li></ul>
</body>
</html>

Position and images

list-style-position decides whether the marker sits outside the text block (default) or inside it, where wrapped lines flow under the marker. list-style-image uses an image as the marker, though ::marker or a ::before pseudo-element gives more control.

The shorthand list-style combines type, position and image: list-style: square inside;

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  body { font-family: system-ui, sans-serif; max-width: 360px; }
  li { background: #e3f2fd; margin: 4px 0; }
  .out { list-style-position: outside; }
  .in  { list-style-position: inside; }
  .img { list-style-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Ccircle cx='6' cy='6' r='5' fill='%23e91e63'/%3E%3C/svg%3E"); }
</style>
</head>
<body>
  <ul class="out"><li>Outside: the marker hangs in the margin and wrapped lines align with the text.</li></ul>
  <ul class="in"><li>Inside: the marker is part of the first line, so wrapped lines go under it.</li></ul>
  <ul class="img"><li>SVG image marker</li><li>Another item</li></ul>
</body>
</html>

Styling the marker with ::marker

The ::marker pseudo-element targets the bullet or number itself. It supports colour, font properties and content.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  body { font-family: system-ui, sans-serif; font-size: 18px; }
  ol li::marker { color: #ff5722; font-weight: 800; font-size: 1.2em; }
  ul li::marker { content: "✔ "; color: #43a047; }
</style>
</head>
<body>
  <ol><li>Preheat the oven</li><li>Mix the batter</li><li>Bake for 25 minutes</li></ol>
  <ul><li>Milk</li><li>Eggs</li><li>Flour</li></ul>
</body>
</html>

Removing default styles: lists as menus

Browsers give lists padding-left (around 40px) and vertical margins. To build a navigation menu from a list, reset these and lay the items out however you need.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  body { font-family: system-ui, sans-serif; }
  .nav { list-style: none; margin: 0; padding: 0; display: flex; background: #263238; }
  .nav a { display: block; padding: 14px 18px; color: #eceff1; text-decoration: none; }
  .nav a:hover { background: #455a64; }
  .card-list { list-style: none; padding: 0; max-width: 300px; }
  .card-list li { padding: 10px 14px; border-left: 5px solid #7e57c2; background: #f3e5f5; margin: 6px 0; }
  .card-list li:nth-child(odd) { background: #ede7f6; }
</style>
</head>
<body>
  <ul class="nav">
    <li><a href="#">Home</a></li><li><a href="#">Blog</a></li><li><a href="#">About</a></li>
  </ul>
  <ul class="card-list"><li>Styled item one</li><li>Styled item two</li><li>Styled item three</li></ul>
</body>
</html>

Tip: Even when markers are hidden, keep using <ul> for menus — screen readers announce "list, 3 items", which helps users navigate.

Test yourself

Which declaration removes bullets from a list?

  1. list-style-type: hidden
  2. list-style: none
  3. bullet: none
  4. display: none

Which pseudo-element lets you colour just the bullet or number?

  1. ::bullet
  2. ::before
  3. ::marker
  4. ::first-letter

With list-style-position: inside, where do wrapped lines go?

  1. Aligned with the text, marker hanging outside
  2. Under the marker
  3. They don't wrap
  4. To the right edge