This tutorial aims to guide you on how to style lists using Cascading Style Sheets (CSS). CSS is a stylesheet language used for describing the look and formatting of a document written in HTML.
By the end of this tutorial, you will learn how to:
Prerequisites:
Knowledge of basic HTML and CSS is required.
CSS provides several properties that can be used to style lists. The list-style-type
property is used to change the bullet point of an unordered list or the numbering system for an ordered list. The list-style-image
property allows you to replace the list-item marker with an image. The list-style-position
property specifies the position of the list-item marker.
/* CSS */
ul {
list-style-type: circle;
}
In the above example, the list-style-type: circle;
changes the bullet points of the unordered list to circles.
/* CSS */
ol {
list-style-type: upper-roman;
}
In the above example, the list-style-type: upper-roman;
changes the numbering system of the ordered list to uppercase Roman numerals.
/* CSS */
ul {
list-style-image: url('marker.png');
}
In the above example, the list-style-image: url('marker.png');
replaces the bullet points with the specified image.
/* CSS */
ul {
list-style-position: inside;
}
In the above example, the list-style-position: inside;
sets the position of the list-item markers to inside.
In this tutorial, we've learned how to style lists using CSS. We've covered how to change the bullet points of an unordered list, the numbering system of an ordered list, how to use an image as the list items marker, and how to change the position of the list items marker.
Solution:
css
/* CSS */
ul {
list-style-type: square;
}
Solution:
css
/* CSS */
ol {
list-style-type: lower-alpha;
}
Solution:
css
/* CSS */
ul {
list-style-image: url('marker.png');
}
To further practice, try combining different CSS properties to style lists. Experiment with different values and observe the changes.