Examples of HTML list elements including unordered lists, ordered lists, and definition lists
Basic unordered list with nested items.
UL {
LI("First item")
LI("Second item")
LI("Third item with nested list") {
UL {
LI("Nested item 1")
LI("Nested item 2")
}
}
}
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item with nested list
<ul>
<li>Nested item 1</li>
<li>Nested item 2</li>
</ul>
</li>
</ul>
Numbered list for sequential items or steps.
OL {
LI("First step")
LI("Second step")
LI("Third step")
LI("Fourth step")
}
.style("counter-reset", "item")
<ol style="counter-reset: item">
<li>First step</li>
<li>Second step</li>
<li>Third step</li>
<li>Fourth step</li>
</ol>
Definition lists for terms and their descriptions.
DL {
DT("HTML")
DD("HyperText Markup Language - the standard markup language for web pages")
DT("CSS")
DD("Cascading Style Sheets - describes how HTML elements are displayed")
DT("JavaScript")
DD("A programming language that enables interactive web pages")
}
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language - the standard markup language for web pages</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets - describes how HTML elements are displayed</dd>
<dt>JavaScript</dt>
<dd>A programming language that enables interactive web pages</dd>
</dl>
Custom styled lists with icons and formatting.
UL {
LI("✅ Featured item with custom styling")
LI("🎯 Another styled item")
LI("🚀 Third styled item")
}
.style("list-style", "none")
.style("padding-left", "0")
<ul style="list-style: none; padding-left: 0">
<li>✅ Featured item with custom styling</li>
<li>🎯 Another styled item</li>
<li>🚀 Third styled item</li>
</ul>
Combining ordered and unordered lists for complex content.
Div {
H3("Recipe Instructions")
OL {
LI("Gather ingredients:")
UL {
LI("2 cups flour")
LI("1 cup sugar")
LI("3 eggs")
}
LI("Mix dry ingredients")
LI("Add wet ingredients")
LI("Bake at 350°F for 30 minutes")
}
}
<div>
<h3>Recipe Instructions</h3>
<ol>
<li>Gather ingredients:</li>
<ul>
<li>2 cups flour</li>
<li>1 cup sugar</li>
<li>3 eggs</li>
</ul>
<li>Mix dry ingredients</li>
<li>Add wet ingredients</li>
<li>Bake at 350°F for 30 minutes</li>
</ol>
</div>