Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS list-style-type Property

Posted in CSS Tutorial
Updated on Oct 03, 2024
By Mari Selvan
👁️ 17 - Views
⏳ 4 mins
💬 1 Comment
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>).

Syntax
Copied
Copy To Clipboard
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

ValueDescription
discA filled circle (default for <ul>).
circleA hollow circle.
squareA filled square.
decimalDecimal numbers, beginning with 1 (default for <ol>).
decimal-leading-zeroDecimal numbers, padded by initial zeros (e.g., 01, 02, 03).
lower-alphaLowercase alphabetical characters (a, b, c, ...).
upper-alphaUppercase alphabetical characters (A, B, C, ...).
lower-romanLowercase Roman numerals (i, ii, iii, ...).
upper-romanUppercase Roman numerals (I, II, III, ...).
noneNo marker.

📄 Example

In this example, we'll demonstrate different list-style-type values applied to an unordered and an ordered list.

index.html
Copied
Copy To Clipboard
<!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:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

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

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy