HTML Unordered and Ordered Lists Tutorial
HTML provides list tags to create unordered (bulleted) and ordered (numbered) lists. Lists are useful for organizing content in a structured format.
1. Unordered Lists
Unordered lists are created using the <ul> tag, with list items defined inside it using <li> tags. By default, items are displayed with bullet points.
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
This example creates a simple bulleted list with three items.
- Item 1
- Item 2
- Item 3
2. Ordered Lists
Ordered lists are created using the <ol> tag, with list items specified using <li> tags. By default, items are displayed with numbers.
<ol>
<li>Step 1</li>
<li>Step 2</li>
<li>Step 3</li>
</ol>
This example creates a numbered list with three steps.
1. Step 1
2. Step 2
3. Step 3
3. Nested Lists
HTML allows you to nest lists, creating lists within lists for complex structures:
<ul>
<li>Item 1
<ul>
<li>Subitem 1.1</li>
<li>Subitem 1.2</li>
</ul>
</li>
<li>Item 2</li>
</ul>
This nested list example creates subitems under "Item 1" in the main list.
- Item 1
- Subitem 1.1
- Subitem 1.2
- Item 2
4. Changing List Styles with CSS
You can customize the appearance of lists with CSS, such as changing bullet styles and numbering types:
ul {
list-style-type: square;
}
ol {
list-style-type: upper-roman;
}
This example changes unordered list bullets to squares and ordered list numbers to Roman numerals.
- List style type square
- List style type upper-roman
5. Conclusion
HTML lists are powerful for organizing content. Unordered and ordered lists provide structure and visual hierarchy, making information easier to read and navigate.
You need to be logged in to participate in this discussion.