When you want to display information on websites in a structured and organized way, lists are one of the best tools. These days, almost no site can be found that does not use lists. Lists in HTML and CSS are beautifully flexible and can be easily customized to change the shape and format to your liking. In HTML, we have two main types of lists: ordered lists and unordered lists. CSS gives us the ability to style each of these lists in various ways to match our design.
Ordered lists are created with the tag
- and unordered lists are created with the tag
- . With CSS, you can change the style and appearance of these lists to your liking; such as changing color, size, type of list markers, etc. You can even replace text markers with custom images easily.
One of the most popular cases for using CSS in list design is changing the type of list marker. You can use properties like
list-style-type
to change the marker type to square, circle, or even none. For this task, simply use thelist-style-type
property and select your desired marker type.Understanding lists is very important, as many elements serve as a standard tool in websites and applications. These tools are not only used for displaying information sequentially but can also be applied in various web contexts.
<ul>
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li>
</ul>
<style>
ul {
list-style-type: square;
color: blue;
}
</style>Line by Line Explanation
<ul>
Starting with an unordered list.
<li>Item One</li>
Displays the first item of the list.
<li>Item Two</li>
Displays the second item of the list.
<li>Item Three</li>
Displays the third item of the list.
<style>
Begins the CSS styling.
ul { list-style-type: square; color: blue; }
Changes the list marker type to square and colors the text blue.
</style>
Ends the CSS styling.
- in HTML. The items in these lists are displayed using the tag