On this page11 sections
  1. Learning Objectives
  2. 1. Marker Types
  3. 2. An Image as the Marker
  4. 3. Marker Position
  5. 4. Removing Default Styles (for Menus)
  6. 5. Colours and the ::marker
  7. 6. The Shorthand
  8. Common Beginner Mistakes
  9. Practice Questions
  10. Practice Answers
  11. Key Takeaways

Lecture 013: Styling Lists

Category3: Text, Fonts & Content
Lecture013 of 057
Estimated video length8 min
TargetCSS3 · any modern browser
LevelBeginner

Bullets and numbers don't have to be plain black dots. CSS can change the marker, use an image or emoji, move it inside the text, remove it completely for menus, and colour each item.


Learning Objectives

  • Change markers with list-style-type and list-style-image
  • Move markers with list-style-position
  • Remove default list styling for menus
  • Colour and space list items, and style the ::marker

1. Marker Types

Example

html
<style>
  ul, ol { margin-bottom: 10px; }
</style>

<ul style="list-style-type: circle;"><li>circle</li><li>circle</li></ul>
<ul style="list-style-type: square;"><li>square</li><li>square</li></ul>
<ol style="list-style-type: upper-roman;"><li>upper-roman</li><li>upper-roman</li></ol>
<ol style="list-style-type: lower-alpha;"><li>lower-alpha</li><li>lower-alpha</li></ol>
<ul style="list-style-type: '✅ ';"><li>A custom string</li><li>Any text works</li></ul>

2. An Image as the Marker

css
ul { list-style-image: url('tick.png'); }

For more control over size and position, many developers use a ::before with a background image instead (Lecture 020).


3. Marker Position

Example

html
<style>
  li { background: #e7f5ff; margin: 4px 0; }
</style>

<ul style="list-style-position: outside;"><li>outside (default): the bullet hangs in the margin, and wrapped lines line up with the text</li></ul>
<ul style="list-style-position: inside;"><li>inside: the bullet sits inside the box, and wrapped lines go under it</li></ul>

4. Removing Default Styles (for Menus)

Example

html
<style>
  ul.plain { list-style: none; margin: 0; padding: 0; }
  ul.plain li { padding: 8px; border-bottom: 1px solid #dee2e6; }
</style>

<ul class="plain">
  <li>Dashboard</li>
  <li>Messages</li>
  <li>Settings</li>
</ul>

list-style: none removes the markers, and padding: 0 removes the left indent. Navigation bars start like this (Lecture 021).


5. Colours and the ::marker

Example

html
<style>
  ol.steps li::marker { color: #e8590c; font-weight: bold; }
  ul.zebra { list-style: none; padding: 0; }
  ul.zebra li { padding: 8px 12px; }
  ul.zebra li:nth-child(odd) { background: #f1f3f5; }
</style>

<ol class="steps">
  <li>Mix flour and water</li>
  <li>Knead for 10 minutes</li>
  <li>Rest for an hour</li>
</ol>

<ul class="zebra">
  <li>Apples</li><li>Bananas</li><li>Cherries</li><li>Dates</li>
</ul>

6. The Shorthand

css
ul { list-style: square inside; }
/* list-style: type position image; */

Common Beginner Mistakes

1. Removing markers but not padding. The list still has a gap on the left.

2. Styling the <ul> colour to colour bullets. That colours the text too. Use ::marker.

3. Typing bullets into the HTML. <li>• Apples</li> doubles up. Let CSS add markers.


Practice Questions

  1. Make a bullet list use squares.
  2. Number an ordered list with Roman numerals.
  3. Remove all list styling for a menu.
  4. What does list-style-position: inside do?
  5. Colour only the numbers of an ordered list red.

Practice Answers

  1. ul { list-style-type: square; }
  2. ol { list-style-type: upper-roman; } (or lower-roman)
  3. ul { list-style: none; margin: 0; padding: 0; }
  4. It moves the marker inside the list item's box, so wrapped lines go under it.
  5. ol li::marker { color: red; }

Key Takeaways

  • list-style-type changes the marker; it can even be a string such as '✅ '.
  • list-style-position decides whether markers sit inside or outside.
  • list-style: none; padding: 0; is the starting point for menus.
  • ::marker styles bullets and numbers on their own.