Overview
In HTML, there are two main types of lists: unordered lists <ul>, which use bullets for each list item and ordered lists <ol>, which use a numbering system.
<ul type="square">
<li>Maserati</li>
<li>Alfa Romeo</li>
<li>Ferrari</li>
</ul>
<ol type="1">
<li>Maserati</li>
<li>Alfa Romeo</li>
<li>Ferrari</li>
</ol>
HTML has limitations to styling a list (or anything really), so CSS is best used for styling the lists.
Note
The following are basic examples. Towards the bottom of this page you’ll find a complete list of all applicable properties, where you can find more information on the properties discussed, and sometimes find more involved properties not discussed on this page.
Changing a Lists Bullets/Numbers with CSS
As with any HTML element, the lists can be styled to change the text color, font, spacing, etc. But lists also use bullets and numbers to differentiate their list items. And using CSS we are given a wider variety of changing the bullets, including using images, or even removing them altogether.
Using bullets and numbers:
ul {
list-style-type: square;
}
ol {
list-style-type: upper-roman;
}
Value | Description |
---|---|
disc | The marker is a filled circle (default on unordered lists) |
armenian | The marker is traditional Armenian numbering |
circle | The marker is a circle |
cjk-ideographic | The marker is plain ideographic numbers |
decimal | The marker is a number (default on ordered lists) |
decimal-leading-zero | The marker is a number with leading zeros (01, 02, 03, etc.) |
georgian | The marker is traditional Georgian numbering |
hebrew | The marker is traditional Hebrew numbering |
hiragana | The marker is traditional Hiragana numbering |
hiragana-iroha | The marker is traditional Hiragana iroha numbering |
katakana | The marker is traditional Katakana numbering |
katakana-iroha | The marker is traditional Katakana iroha numbering |
lower-alpha | The marker is lower-alpha (a, b, c, d, e, etc.) |
lower-greek | The marker is lower-greek |
lower-latin | The marker is lower-latin (a, b, c, d, e, etc.) |
lower-roman | The marker is lower-roman (i, ii, iii, iv, v, etc.) |
none | No marker is shown |
square | The marker is a square |
upper-alpha | The marker is upper-alpha (A, B, C, D, E, etc.) |
upper-greek | The marker is upper-greek |
upper-latin | The marker is upper-latin (A, B, C, D, E, etc.) |
upper-roman | The marker is upper-roman (I, II, III, IV, V, etc.) |
initial | Sets this property to its default value |
inherit | Inherits this property from its parent element |
Using Images:
ul {
list-style-image: url("my_marker.jpg");
}
Removing Bullets and Indentation
This keeps the list structure, but does away with the list look.
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
List Properties
- CSS – list-style PropertyThe list-style property is a shorthand property for list-style-type, list-style-position, and list-style-image.
- CSS – list-style-image PropertyThe list-style-image property replaces the list-item marker with an image. The list-style-type property should also be specified as a backup.
- CSS – list-style-position PropertyThe list-style-position property specifies the position of the list-item markers (bullet points).
- CSS – list-style-type PropertyThe list-style-type specifies the type of list-item marker in a list.
CSS Notes:
- The “inherit”, “initial” and “unset” keywords can be used with any CSS property to set its value
- In CSS there are many ways to express a color value in a property
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.