CSS Lists
The CSS list properties allow you to set different list item markers for ordered lists and unordered lists.
CSS Lists
In HTML, there are two main types of lists:
- unordered lists (
<ul>) - the list items are marked with bullets - ordered lists (
<ol>) - the list items are marked with numbers or letters
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
Example 1: List Item Markers
The list-style-type property specifies the type of list item marker.
- Circle type
- Tea
- Coca Cola
- Square type
- Tea
- Coca Cola
- Upper-roman type
- Tea
- Coca Cola
- Lower-alpha type
- Tea
- Coca Cola
Example 2: An Image as The List Item Marker
The list-style-image property specifies an image as the list item marker.
- Coffee
- Tea
- Coca Cola
Example 3: Position The List Item Markers
The list-style-position property specifies the position of the list-item markers (bullet points).
- "outside" (default): The bullet points are outside the list item. The start of each line of a list item aligns vertically.
- "inside": The bullet points are 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.
Example 4: Remove Default Settings
The list-style-type:none property can also be used to remove the markers/bullets. Note that the list also has default margin and padding. To remove this, add margin:0 and padding:0 to <ul> or <ol>.
- Coffee
- Tea
- Coca Cola
Example 5: Styling List With Colors
We can also style lists with colors, to make them look a little more interesting.
- Coffee
- Tea
- Coca Cola