top of page
Writer's picturecompnomics

List It Up: Unordered, Ordered, and Definition Lists in HTML

Here's the HTML code to explain different types of lists:


1. Unordered List:

  • Represented by the <ul> tag.

  • Items are marked with bullets by default.

  • Use the <li> tag for each item in the list.









<h2>Unordered List</h2>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

2. Ordered List:

  • Represented by the <ol> tag.

  • Items are numbered by default.

  • Use the <li> tag for each item in the list.

  • You can optionally specify the starting number using the start attribute on the <ol> tag.

<h2>Ordered List</h2>
<ol>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ol>

<h2>Ordered List with custom starting number</h2>
<ol start="3">
  <li>Item 3</li>
  <li>Item 4</li>
</ol>

3. Definition List:

  • Represented by the <dl> tag.

  • Used to define terms and their descriptions.

  • Use the <dt> tag for the term and <dd> tag for the description.

<h2>Definition List</h2>
<dl>
  <dt>Coffee</dt>
  <dd>A brewed drink prepared from roasted coffee beans.</dd>
  <dt>Tea</dt>
  <dd>A hot beverage made from the leaves of the Camellia sinensis plant.</dd>
</dl>

Remember:

  • Each list item tag (<li><dt><dd>) needs a closing tag.

  • You can style these lists using CSS for different appearances like bullet types, numbering styles, and more.


17 views0 comments

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page