Two types of list exist in CSS i.e. Unordered lists and Ordered Lists
In unordered lists, the list items are marked with bullets.
In ordered lists, the list items are marked with numbers and alphabet.
The CSS list properties allow you to:
- Set different list item markers for ordered lists
- Set different list item markers for unordered lists
- Set an image as the list item marker
- Add background colors to lists and list items
List Item Marker: This property specifies the type of item marker i.e. unordered list or ordered
Different List Item Markers
The value can be the following:
- decimal , eg :1,2,3,etc
- decimal-leading-zeroes , eg :01,02,03,04,etc
- lower-alpha, eg : a,b,c,etc
- upper-alpha, eg : A,B,C,etc
The following example shows some of the available list item markers:
An Image as The List Item Marker
The list-style-image property specifies an image as the list item marker:
Position The List Item Markers
The list-style-position property specifies the position of the list-item markers (bullet points).
“list-style-position: outside;” means that the bullet points will be outside the list item. The start of each line of a list item will be aligned vertically.
“list-style-position: inside;” means that the bullet points will be inside the list item. As it is part of the list item, it will be part of the text and push the text at the start.
List – Shorthand property
The list-style property is a shorthand property. It is used to set all the list properties in one declaration:
When using the shorthand property, the order of the property values are:
- list-style-type (if a list-style-image is specified, the value of this property will be displayed if the image for some reason cannot be displayed)
- list-style-position (specifies whether the list-item markers should appear inside or outside the content flow)
- list-style-image (specifies an image as the list item marker)
Styling List With Colors
We can also style lists with colors, to make them look a little more interesting.
Anything added to the <ol> or <ul> tag, affects the entire list, while properties added to the <li> tag will affect the individual list items:
All CSS List Properties
You may also like: CSS Text