CSS Properties
CSS list-style-type Property
Photo Credit to CodeToFun
🙋 Introduction
The list-style-type
property in CSS is used to define the appearance of the list item marker for ordered lists (<ol>) and unordered lists (<ul>).
This property allows you to customize the bullets, numbers, or other markers that appear before each list item, enhancing the visual presentation of lists on your website.
💡 Syntax
The syntax for the list-style-type
property is simple and can be applied to list elements (<ul>, <ol>, <li>).
element {
list-style-type: type;
}
Here, type specifies the marker type, which can be a predefined keyword or a custom marker.
🎛️ Default Value
The default value of the list-style-type
property depends on the type of list:
- For unordered lists (<ul>), the default value is disc.
- For ordered lists (<ol>), the default value is decimal.
🏠 Property Values
Value | Description |
---|---|
disc | A filled circle (default for <ul>). |
circle | A hollow circle. |
square | A filled square. |
decimal | Decimal numbers, beginning with 1 (default for <ol>). |
decimal-leading-zero | Decimal numbers, padded by initial zeros (e.g., 01, 02, 03). |
lower-alpha | Lowercase alphabetical characters (a, b, c, ...). |
upper-alpha | Uppercase alphabetical characters (A, B, C, ...). |
lower-roman | Lowercase Roman numerals (i, ii, iii, ...). |
upper-roman | Uppercase Roman numerals (I, II, III, ...). |
none | No marker. |
📄 Example
In this example, we'll demonstrate different list-style-type
values applied to an unordered and an ordered list.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS list-style-type Example</title>
<style>
ul {
list-style-type: square;
}
ol {
list-style-type: upper-roman;
}
</style>
</head>
<body>
<h1>Custom List Style Types</h1>
<h2>Unordered List</h2>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<h2>Ordered List</h2>
<ol>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ol>
</body>
</html>
🖥️ Browser Compatibility
The list-style-type
property is widely supported across all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. This property has been a part of CSS for a long time, so it works reliably across various browser versions.
🎉 Conclusion
The list-style-type
property provides a simple yet effective way to customize the appearance of list markers on your website.
Whether you're aiming for a standard look with numbers and bullets or a more unique style with custom markers, this property gives you the flexibility to enhance the presentation of your lists. Experiment with different values to find the perfect match for your website's design.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (CSS list-style-type Property), please comment here. I will help you immediately.