▲Wirig Diagram Hot
▲ ▲ ▼

Understanding UL and LI in CSS: A Comprehensive Guide

By

If you're delving into CSS (Cascading Style Sheets) and wondering about its seemingly simple yet powerful list elements, you've come to the right place. In this article, we'll unravel the mysteries of two common list elements in CSS: `

    ` and `
  • `.

    Understanding these elements is crucial as they allow you to create well-structured, readable lists that search engines love, thereby improving your SEO. So, let's dive right in!

    Understanding Unordered Lists: `
      ` and `
    • `

    Unordered lists are perfect when you want to present a list of items that aren't ranked or don't have a specific order. They're identified by the `

      ` tag, with each item in the list defined by the `
    • ` tag.

      By default, unordered lists use bullets, but with CSS, you can customize these markers or even remove them. Let's explore how to use and style `

        ` and `
      • ` elements.

        Creating an Unordered List

        To create an unordered list, wrap your `

      • ` elements in a `
          ` tag. Here's a simple example:

          <ul>
            <li>Item 1</li>
            <li>Item 2</li>
            <li>Item 3</li>
          </ul>

          This will create a list of items with default styling.

          Styling Unordered Lists with CSS

          Now that you know how to create unordered lists, let's see how CSS can enhance them.

          To change the bullet style, use the `list-style-type` property. To remove bullets entirely, set it to `none`. Here's how:

          ul {
            list-style-type: none;
            padding-left: 20px;
          }
          
          li::before {
            content: "•";
            color: #333;
            margin-right: 10px;
          }

          This CSS will remove the default bullets and replace them with custom gray-filled circles.

          Navigating Ordered Lists: `
            ` and `
          1. `

          Ordered lists are perfect for steps, rankings, or any scenario where order matters. Each item in an ordered list is also defined by the `

        • ` tag, but the container is an `
            ` tag.

            By default, ordered lists use numbers, but you can customize the markers or even replace them with custom text using list-style-type and generated content.

            Creating an Ordered List

            To create an ordered list, simply wrap your `

          1. ` elements in an `
              ` tag:

              <ol>
                <li>First item</li>
                <li>Second item</li>
                <li>Third item</li>
              </ol>

              This will create a list of items with default numbering.

              Styling Ordered Lists with CSS

              The possibilities for styling ordered lists are vast. You can change the list numbers, add custom marks, or even replace numbers with text using `list-style-type` and `li::marker` pseudo-element (in browsers that support it). Here's an example:

              ol.lower-alpha {
                list-style-type: lower-alpha;
              }
              
              ol.upper-roman {
                list-style-type: upper-roman;
              }

              This CSS will modify the list markers to lowercase Latin (a, b, c...) and uppercase Roman (I, II, III...) for two different ordered lists.

              Mastering `

                ` and `
              • ` elements in CSS unleashes a world of possibilities for presenting content in a structured, search engine-friendly manner. So, don't hesitate to deploy them in your web projects. Happy coding!

CSS Tree View with Lines Using ul li
CSS Tree View with Lines Using ul li
a screenshot of a computer screen with some type of text in the bottom right corner
a screenshot of a computer screen with some type of text in the bottom right corner
Html and css
Html and css
HTML Lists: <ul> vs <ol> – When to Use Which? 📝
HTML Lists: <ul> vs <ol> – When to Use Which? 📝
Custom Select Dropdown Using ul li in JavaScript
Custom Select Dropdown Using ul li in JavaScript
3 Ways to Apply CSS in HTML | Inline, Internal & External (2025 Guide)
3 Ways to Apply CSS in HTML | Inline, Internal & External (2025 Guide)
Inline vs Block Elements | HTML Display Explained
Inline vs Block Elements | HTML Display Explained
🎨 CSS Introduction | Learn CSS Basics (Lesson 1)
🎨 CSS Introduction | Learn CSS Basics (Lesson 1)
CSS Cheat Sheet for Beginners (2026) | Ultimate CSS Quick Reference Guide
CSS Cheat Sheet for Beginners (2026) | Ultimate CSS Quick Reference Guide
25 CSS TRICKS EVERY FRONTEND DEVELOPER SHOULD KNOW
25 CSS TRICKS EVERY FRONTEND DEVELOPER SHOULD KNOW
CSS Display Property Explained (Block vs Inline vs Inline-Block vs None) | Beginner CSS Guide
CSS Display Property Explained (Block vs Inline vs Inline-Block vs None) | Beginner CSS Guide
What Is CSS?
What Is CSS?
The CSS Cheat Sheet Every Web Designer Secretly Uses
The CSS Cheat Sheet Every Web Designer Secretly Uses
💬 Comments ↗ Share ★ Save
AD