CSS Styling Lists
CSS Styling Lists
asp
Unordered Lists:
Coffee
Tea
Coca Cola
Coffee
Tea
Coca Cola
Ordered Lists:
1. Coffee
2. Tea
3. Coca Cola
1. Coffee
2. Tea
3. Coca Cola
unordered lists (<ul>) - the list items are marked with bullets
ordered lists (<ol>) - the list items are marked with numbers or letters
The following example shows some of the available list item markers:
Example
1 of 4 10/27/2019, 3:17 PM
CSS Styling Lists https://www.w3schools.com/css/css_list.asp
ul.a {
list-style-type: circle;
}
ul.b {
list-style-type: square;
}
ol.c {
list-style-type: upper-roman;
}
ol.d {
list-style-type: lower-alpha;
}
Try it Yourself »
Note: Some of the values are for unordered lists, and some for ordered lists.
"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. This is default:
"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:
Example
ul.a {
list-style-position: outside;
}
ul.b {
2 of 4 10/27/2019, 3:17 PM
CSS Styling Lists https://www.w3schools.com/css/css_list.asp
list-style-position: inside;
}
Try it Yourself »
When using the shorthand property, the order of the property values are:
If one of the property values above are missing, the default value for the missing
property will be inserted, if any.
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:
Example
ol {
background: #ff9999;
padding: 20px;
}
ul {
background: #3399ff;
padding: 20px;
}
ol li {
background: #ffe5e5;
3 of 4 10/27/2019, 3:17 PM
CSS Styling Lists https://www.w3schools.com/css/css_list.asp
padding: 5px;
margin-left: 35px;
}
ul li {
background: #cce5ff;
margin: 5px;
}
Result:
1. Coffee
2. Tea
3. Coca Cola
Coffee
Tea
Coca Cola
Try it Yourself »
More Examples
Customized list with a red left border
This example demonstrates how to create a list with a red left border.
4 of 4 10/27/2019, 3:17 PM