List Elements of HTML
HTML provides various elements to create lists and organize content effectively. Lists are useful for presenting items in a structured manner. Below are the core list elements in HTML:
<ul>: Unordered Lists
The <ul>
element is used to create an unordered list, which displays list items with bullet points.
Example:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ol>: Ordered Lists
The <ol>
element is used to create an ordered list, which displays list items with numbers or letters, indicating a specific order.
Example:
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<li>: List Items
The <li>
element is used to define an item in a list, whether it’s in an unordered list (<ul>
) or an ordered list (<ol>
).
Example:
<ul>
<li>Item A</li>
<li>Item B</li>
</ul>
<dl>: Description Lists
The <dl>
element is used to create a description list, where each term is defined by a description. It is useful for glossaries or lists of terms and their definitions.
Example:
<dl>
<dt>Term 1</dt>
<dd>Description for Term 1</dd>
<dt>Term 2</dt>
<dd>Description for Term 2</dd>
</dl>
<dt> and <dd>: Term and Description
The <dt>
element is used to define a term in a description list, while the <dd>
element is used to provide a description for the term.
Example:
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
Comments
Post a Comment