Lists allow you to organize and structure information on a web page. They are used everywhere: navigation menus, enumerations, step-by-step instructions, timelines...
Without lists, content would be disorganized and difficult to read. With lists, you can create clear and elegant presentations!
<ul>)For elements without a particular order.
<ul>
<li>First element</li>
<li>Second element</li>
<li>Third element</li>
</ul>
<ol>)For elements that follow a specific order.
<ol>
<li>First step</li>
<li>Second step</li>
<li>Third step</li>
</ol>
By default, lists display bullets (•) or numbers. You can remove them with CSS :
<!DOCTYPE html>
<html>
<head>
<title>List without bullets</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul class="no-bullets">
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
</ul>
</body>
</html>
list-style-type: none; property removes bullets, and padding: 0; removes the left offset.Here's how to transform a simple list into a modern timeline :
<!DOCTYPE html>
<html>
<head>
<title>Timeline</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul class="timeline">
<li>
<strong>2010</strong>
Project launch
</li>
<li>
<strong>2015</strong>
First public version
</li>
<li>
<strong>2024</strong>
Current version
</li>
</ul>
</body>
</html>
<ul>
<li><strong>2010</strong> Project launch</li>
<li><strong>2015</strong> First public version</li>
<li><strong>2024</strong> Current version</li>
</ul>
.timeline li {
background-color: #f0f0f0;
padding: 15px;
border-left: 4px solid #3498db;
border-radius: 5px;
}
| Property | Description | Example |
|---|---|---|
list-style-type | Changes the bullet type | none, circle, square |
padding | Inner spacing | padding: 10px; |
margin | Outer spacing | margin-bottom: 15px; |
background-color | Background color | background-color: #f0f0f0; |
border-left | Left border | border-left: 3px solid blue; |
border-radius | Rounded corners | border-radius: 5px; |
Lists are perfect for creating menus :
<!DOCTYPE html>
<html>
<head>
<title>Navigation menu</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</body>
</html>
list-style-type: none;padding and margin to space your elements harmoniouslyborder-left) to create a modern effectborder-radius to round the corners of your elements:hover effect to make your lists interactive