What are the HTML lists?
HTML provides tags for creating both ordered (numbered) and unordered (bulleted) lists, as well as defining list items within these lists. Here's how you can create ordered and unordered lists in HTML:
Ordered Lists (
<ol>
): Ordered lists are used when you want to present items in a specific numerical or alphabetical order. To create an ordered list, use the<ol>
element, and within it, define list items using the<li>
element. Each list item is automatically numbered by the browser.html code<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>
This will render as:
- Item 1
- Item 2
- Item 3
You can also change the type of numbering (e.g., Roman numerals or letters) by using the
type
attribute of the<ol>
element:html code<oltype="I"><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>
This will render as: I. Item 1 II. Item 2 III. Item 3
Unordered Lists (
<ul>
): Unordered lists are used when the order of items does not matter, and you want to create a bulleted list. To create an unordered list, use the<ul>
element and define list items using the<li>
element.html code<ul><li>Item A</li><li>Item B</li><li>Item C</li></ul>
This will render as:
- Item A
- Item B
- Item C
You can also change the type of bullet points using CSS.
Nested Lists: You can also nest lists inside other lists to create sublists. For example, you can nest an unordered list within an ordered list, or vice versa.
html code<ol><li>Main item 1</li><li>Main item 2 <ul><li>Subitem 1</li><li>Subitem 2</li></ul></li><li>Main item 3</li></ol>
This will render as:
- Main item 1
- Main item 2
- Subitem 1
- Subitem 2
- Main item 3
Remember that HTML provides the structure, and you can apply CSS for styling, such as changing the bullet points' appearance, adjusting spacing, or altering the numbering style.
Outstanding material
ReplyDelete