An ordered list in HTML is a list of items that are displayed in a specific order, with each item numbered. You can create an ordered list using the <ol>
element. The <ol>
element represents an ordered list, and it should contain one or more <li>
elements, which represent the individual items in the list.
Here is an example of an ordered list in HTML:
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
The output of this code would be:
- Item 1
- Item 2
- Item 3
An unordered list in HTML is a list of items that are displayed in no particular order, with each item marked with a bullet point. You can create an unordered list using the <ul>
element. The <ul>
element represents an unordered list, and it should contain one or more <li>
elements, which represent the individual items in the list.
Here is an example of an unordered list in HTML:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
The output of this code would be:
- Item 1
- Item 2
- Item 3
list-style-type
property in a <style>
element or an external style sheet. For example, you can use the square
value to display square bullets:ul {
list-style-type: square;
}
</style>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
The output of this code would be:
- Item 1
- Item 2
- Item 3
<li>
element to create nested lists, by placing another list inside a <li>
element.<li>Item 1</li>
<li>Item 2
<ul>
<li>Subitem 1</li>
<li>Subitem 2</li>
<li>Subitem 3</li>
</ul>
</li>
<li>Item 3</li>
</ul>
The output of this code would be:
- Item 1
- Item 2
- Subitem 1
- Subitem 2
- Subitem 3
- Item 3
0 Comments