Codectionary / Developer documentation / CSS

List Styling

list-style controls how list markers (bullets or numbers) appear on <ul>/<ol> elements. list-style-type sets the marker style, list-style-position controls whether markers sit inside or outside the content box, and list-style: none is the standard way to remove markers entirely, commonly used when repurposing a list for navigation.

Syntax

list-style: type position image;

Examples

Removing Default List Styling

The standard reset applied when using a <ul> for non-list purposes, like navigation.

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 16px;
}

Custom Marker Styles

Changing marker type and using the ::marker pseudo-element for further styling.

ol { list-style-type: upper-roman; } /* I, II, III... */
ul { list-style-type: square; }

li::marker {
  color: #3b82f6; /* styles just the bullet/number, not the text */
  font-weight: bold;
}

Parameters and values

  • list-style-type (disc | circle | square | decimal | none): Sets the marker appearance
  • list-style-position (inside | outside): Whether markers sit inside or outside the content box
  • ::marker (pseudo-element): Targets just the marker for additional styling

Best practices

  • Set list-style: none and remove default padding when using a <ul>/<ol> for navigation or other non-literal-list purposes
  • Use the ::marker pseudo-element to style bullets/numbers directly, rather than hiding markers and faking them with ::before
  • Keep semantic list markup (<ul>/<ol>/<li>) even when visually removing markers - screen readers still announce it as a list, which is often the correct behavior
  • list-style-position: inside wraps text under the marker; outside (the default) keeps wrapped text aligned with the first line, not the marker

At a glance

Purpose
Presentation and layout
File extension
.css
Runs in
Web browsers
Usually used with
HTML and JavaScript

Specifications & further reading

Related CSS documentation