SyntaxStudy
Sign Up
HTML Styling Lists with CSS
HTML Intermediate 6 min read

Styling Lists with CSS

Styling Lists with CSS

CSS gives you precise control over every aspect of list appearance. The shorthand property list-style combines list-style-type, list-style-position, and list-style-image into one declaration.

list-style-position

The list-style-position property controls whether the bullet or number sits outside (default — left of the text block) or inside (within the text flow, so wrapped lines align under the marker). For fully custom markers with exact positioning, use list-style: none and generate a marker via the ::before pseudo-element with content and counter().

Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>List Styling</title>
  <style>
    /* Navigation menu */
    nav ul {
      list-style: none;
      margin: 0; padding: 0;
      display: flex; gap: 16px;
    }
    nav a { text-decoration: none; color: #333; }
    nav a:hover { color: #0066cc; }

    /* Custom bullet with ::before */
    ul.custom li {
      list-style: none;
      padding-left: 20px;
      position: relative;
    }
    ul.custom li::before {
      content: "✔";
      position: absolute;
      left: 0;
      color: green;
    }
  </style>
</head>
<body>
  <nav><ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">Blog</a></li>
    <li><a href="#">Contact</a></li>
  </ul></nav>

  <ul class="custom">
    <li>Feature one</li>
    <li>Feature two</li>
    <li>Feature three</li>
  </ul>
</body>
</html>
Pro Tip

For navigation menus built from <ul>, always keep the <ul>/<li> structure in the HTML and remove bullets with CSS — the semantic list structure benefits keyboard users and screen readers even when it looks like a menu bar.