HTML Lists:
HTML provides three types of lists: ordered lists (`<ol>`), unordered lists (`<ul>`), and definition lists (`<dl>`). Lists are used to organize and structure content on a webpage.
Ordered List (`<ol>`):
An ordered list is a numbered list where each list item is preceded by a numerical or alphabetical identifier.
html
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
Unordered List (`<ul>`):
An unordered list is a bulleted list where each list item is preceded by a bullet point.
html
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>
Definition List (`<dl>`):
A definition list is used to define terms, usually consisting of a term (`<dt>`) and its definition (`<dd>`).
html
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
</dl>
Example of Ordered list |
Here’s a complete example combining all three types of lists:
html
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>HTML Lists Example</title>
<style>
ul, ol, dl {
margin-bottom: 20px;
}
</style>
</head>
<body>
<h2>Ordered List</h2>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
<h2>Unordered List</h2>
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>
<h2>Definition List</h2>
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
</dl>
</body>
</html>
In this example, the CSS style is used to provide some spacing between different types of lists. Lists are a fundamental part of structuring content in HTML and are often used to present information in a clear and organized manner.