Learn to create and style flexible, bullet-pointed lists with HTML!
In this tutorial, we'll explore the power of HTML unordered lists (UL) to organize content, enhance readability, and make your web pages more user-friendly. You'll discover how to create lists, add custom bullet points, and style them according to your design needs.
Unordered lists (UL) are a fundamental HTML element used to group items without a specific order. They are represented by the <ul> tag. Each list item is wrapped within the <li> tag.
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>By default, browsers display unordered lists with bullet points.
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
š Output:
- Apple
- Banana
- CherryYou can customize the bullet points using the list-style-type property.
<ul style="list-style-type: square;">
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
š Output:
ā” Apple
ā” Banana
ā” CherryFor more advanced styling options, you can use CSS.
ul {
padding: 0;
list-style-type: none;
}
ul li {
background-color: #f2f2f2;
border: 1px solid #ccc;
padding: 10px;
}<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
š Output:
Apple
Banana
Cherry
(with custom styling)Create hierarchical lists by nesting <ul> and <li> tags.
<ul>
<li>Fruit</li>
<ul>
<li>Citrus Fruit</li>
<li>Citrus Fruit 2</li>
</ul>
<li>Berry</li>
</ul>
š Output:
- Fruit
- Citrus Fruit
- Citrus Fruit 2
- Berry