HTML List
HTML lists are a way to display a collection of items on a web page. There are three types of lists in HTML:
-
Ordered List (<ol>): Used for lists where the order of items is important. Each item is numbered automatically.
Example:
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
Output:
- First item
- Second item
- Third item
-
Unordered List (<ul>): Used for lists where the order of items does not matter. Each item is marked with a bullet point.
Example:
<ul>
<li>Apples</li>
<li>Oranges</li>
<li>Bananas</li>
</ul>
Output:
-
Description List (<dl>): Used for lists where each item has a term and a description. This is often used for glossary terms or definitions.
Example:
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
<dt>JavaScript</dt>
<dd>A programming language for web development</dd>
</dl>
Output:
- HTML: HyperText Markup Language
- CSS: Cascading Style Sheets
- JavaScript: A programming language for web development
Each list item in <ol> and <ul> is marked up with the <li> (list item) tag, while in a <dl>, terms are marked with <dt> (definition term) and descriptions with <dd> (definition description).