Types of Lists

Index

  1. List
  2. Unordered List
  3. Ordered List
  4. Definition List

List

In HTML, we can give numbers, unnumbered, and lists to the different text using simple tags. We can also use nested lists with a list. HTML editor automatically takes the space between the bullet or list number in a text, we do not need to mention it. Neither (as yet) do we have control over what type of bullet will be used as each browser is different.

Unordered lists

<ul> tag is used to Unordered any list followed by the actual list items, which are marked with the <li> tag. The list is ended with the ending tag </ul> The CSS list-style-type property is used to define the style of the list item marker. It can have one of the following values:

  • disc: - Sets the list item marker to a bullet (default)
  • circle: - Sets the list item marker to a circle
  • square: - Sets the list item marker to a square
  • none: - The list items will not be marked
Example:
<!DOCTYPE html>
<html>
  <body>
    <h2>Unordered List with Disc Bullets</h2>
    <ul style="list-style-type:disc;">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>  
    <h2>Unordered List with Circle Bullets</h2>
    <ul style="list-style-type:circle;">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>  
    <h2>Unordered List with Square Bullets</h2>
    <ul style="list-style-type:square;">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
    <h2>Unordered List without Bullets</h2>
    <ul style="list-style-type:none;">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul> 
  </body>
</html>
Output:

Ordered List

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. The list items will be marked with numbers by default: The type attribute of the <ol> tag defines the type of the list item marker:

  • type="1": - The list items will be numbered with numbers (default)
  • type="A": - The list items will be numbered with uppercase letters
  • type="a": - The list items will be numbered with lowercase letters
  • type="I": - The list items will be numbered with uppercase roman numbers
  • type="i": - The list items will be numbered with lowercase roman numbers
Example:
<!DOCTYPE html>
<html>
  <body>
    <h2>Ordered List with Numbers</h2>
    <ol type="1" start="50">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ol>  
    <h2>Ordered List with Letters</h2>
    <ol type="A">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ol>  
    <h2>Ordered List with Lowercase Letters</h2>
    <ol type="a">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ol> 
    <h2>Ordered List with Roman Numbers</h2>
    <ol type="I">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ol>  
    <h2>Ordered List with Lowercase Roman Numbers</h2>
    <ol type="i">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ol>  
  </body>
</html>
Output:

Definition Lists

A description list is a list of terms, with a description of each term. The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag describes each term:

Example:
<!DOCTYPE html>
<html>
  <body>
    <h2>A Description List</h2>
    <dl>
      <dt>Coffee</dt>
      <dd>- black hot drink</dd>
      <dt>Milk</dt>
      <dd>- white cold drink</dd>
    </dl>
  </body>
</html>
Output:

Comments

Popular posts from this blog

Adding Graphics to HTML Documents

Table

Introduction to HTML