Explain various types of lists that can be created in HTML giving suitable example

HTML Lists

In this tutorial you will learn how to create different types of lists in HTML.

HTML - Lists


Advertisements

Previous Page
Next Page

HTML offers web authors three ways for specifying lists of information. All lists must contain one or more list elements. Lists may contain −

  • <ul> − An unordered list. This will list items using plain bullets.

  • <ol> − An ordered list. This will use different schemes of numbers to list your items.

  • <dl> − A definition list. This arranges your items in the same way as they are arranged in a dictionary.

HTML Lists

In this article, we will know the HTML List, along with understanding its types, various ways to implement them, through the example.

A list is a record of short pieces of related information or used to display the data or any information in web pages in the ordered or unordered form. For instance, to purchase the items, we need to prepare a list that can either be ordered or unordered list which helps us to organize the data & easy to find the item. Please refer to the HTML <li> type Attribute article for the various types of attributes that can be used with the ordered & unordered list.

Example: The below example illustrates the use of the unordered & ordered list in HTML.




<!DOCTYPE html>
<html>
<head>
<title>GeeksforGeeks</title>
</head>
<body>
<h2>Welcome To GeeksforGeeks Learning</h2>
<h5>List of available courses</h5>
<ul>
<li>Data Structures & Algorithm</li>
<li>Web Technology</li>
<li>Aptitude & Logical Reasoning</li>
<li>Programming Languages</li>
</ul>
<h5>Data Structures topics</h5>
<ol>
<li>Array</li>
<li>Linked List</li>
<li>Stacks</li>
<li>Queues</li>
<li>Trees</li>
<li>Graphs</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

HTML List

Supported Tags: These tags are used in HTML listing.



  • HTML <ul> Tag
  • HTML <ol> Tag
  • HTML <dl> Tag

The HTML Unordered List: An unordered list starts with the “ul” tag. Each list item starts with the “li” tag. The list items are marked with bullets i.e small black circles by default.

Syntax:

<ul> list of items </ul>

Attribute: This tag contains two attributes which are listed below:

  • compact: It will render the list smaller.
  • type: It specifies which kind of marker is used in the list.

Note: The <ul> attributes are not supported by HTML5.

Example: This example describes the unordered list.




<!DOCTYPE html>
<html>
<body>
<h2>Grocery list</h2>
<ul>
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ul>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Unordered List

HTML unordered list has various list item markers:

Example 1: The Disc can be used to set the list item marker to a bullet i.e default.




<!DOCTYPE html>
<html>
<head>
<title>HTML ul tag</title>
</head>
<body>
<h2>GeeksforGeeks</h2>
<h2>Unordered List with Disc Bullets</h2>
<p>GeeksforGeeks courses List:</p>
<ul style="list-style-type:disc">
<li>Geeks</li>
<li>Sudo</li>
<li>Gfg</li>
<li>Gate</li>
<li>Placement</li>
</ul>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Unordered List with disc item maker

Example 2: The Circle can be used toset the list item marker to a circle.




<!DOCTYPE html>
<html>
<body>
<h2>GeeksforGeeks</h2>
<h2>Unordered List with Circle Bullets</h2>
<p>GeeksforGeeks courses List:</p>
<ul style="list-style-type: circle">
<li>Geeks</li>
<li>Sudo</li>
<li>Gfg</li>
<li>Gate</li>
<li>Placement</li>
</ul>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Unordered List with circle item maker

Example 3: TheSquare can be used to set the list item marker to a square.




<!DOCTYPE html>
<html>
<body>
<h2>GeeksforGeeks</h2>
<h2>Unordered List with Square Bullets</h2>
<p>GeeksforGeeks courses List:</p>
<ul style="list-style-type: square">
<li>Geeks</li>
<li>Sudo</li>
<li>Gfg</li>
<li>Gate</li>
<li>Placement</li>
</ul>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Unordered List with square item maker

Example 4: It’s none that can be used to set the list item marker with no mark.




<!DOCTYPE html>
<html>
<body>
<h2>GeeksforGeeks</h2>
<h2>Unordered List with No Bullets</h2>
<p>GeeksforGeeks courses List:</p>
<ul style="list-style-type: none">
<li>Geeks</li>
<li>Sudo</li>
<li>Gfg</li>
<li>Gate</li>
<li>Placement</li>
</ul>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Unordered List with none item maker

Example: Nested Unordered List, It is used to nest the list items ie., list inside another list.




<!DOCTYPE html>
<html>
<body>
<h2>GeeksforGeeks</h2>
<h2>Nested Unordered List</h2>
<p>GeeksforGeeks courses List:</p>
<ul>
<li>DSA</li>
<ul>
<li>Array</li>
<li>Linked List</li>
<li>stack</li>
<li>Queue</li>
</ul>
<li>Web Technologies</li>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<li>Aptitude</li>
<li>Gate</li>
<li>Placement</li>
</ul>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Nested Unordered List

HTML Ordered List: An ordered list starts with the “ol” tag. Each list item starts with the “li” tag. The list items are marked with numbers by default.

Syntax:

<ol> <li>Item1</li> <li>Item2</li> <li>Item3</li> </ol>

Attributes:

  • compact: It defines the list should be compacted (compact attribute is not supported HTML5. Use CSS instead.).
  • reversed: It defines that the order will be descending.
  • start: It defines that from which number or alphabet the order will start.
  • type: It defines which type(1, A, a, I, and i) of the order you want in your list numeric, alphabetic, or roman numbers.

Example:This example illustrates the use of the reverse attribute, control list counting & type attribute.




<!DOCTYPE html>
<html>
<head>
<title>HTML ol tag</title>
</head>
<body>
<h2 style="color: green">GeeksforGeeks</h2>
<h3>HTML ol tag</h3>
<p>reversed attribute</p>
<ol reversed>
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
</ol>
<p>start attribute</p>
<ol start="5">
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
</ol>
<p>type attribute</p>
<ol type="i">
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Ordered List with different list style

HTML ordered list has various list item markers: The type attribute of the <ol> tag defines the type of the list item marker.

Example 1: The list items will be numbered with numbers i.e default.




<!DOCTYPE html>
<html>
<body>
<h2>Ordered List with Numbers</h2>
<ol type="1">
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Ordered List withnumeric item maker

Example 2: Type=”A”, this list of items will be numbered with uppercase letters.




<!DOCTYPE html>
<html>
<body>
<h2>Ordered List with Letters</h2>
<ol type="A">
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Ordered List withcapital alphabetic item maker

Example 3: Type=”a”, this list items will be numbered with lowercase letters.




<!DOCTYPE html>
<html>
<body>
<h2>Ordered List with Lowercase Letters</h2>
<ol type="a">
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Ordered List withsmall alphabetic item maker

Example 4: Type=”I”, this list items will be numbered with uppercase roman numbers.




<!DOCTYPE html>
<html>
<body>
<h2>Ordered List with Roman Numbers</h2>
<ol type="I">
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Ordered List withuppercase roman numbers

Example 5: Type=”i”, this list items will be numbered with lowercase roman numbers.




<!DOCTYPE html>
<html>
<body>
<h2>Ordered List with Lowercase Roman Numbers</h2>
<ol type="i">
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Ordered List withlowercase roman numbers

Example 6: Nested ordered list, a nested ordered list is a list that has a list inside another list.




<!DOCTYPE html>
<html>
<body>
<h2>GeeksforGeeks</h2>
<h2>Nested Ordered List</h2>
<ol>
<li>Coffee</li>
<li> Tea
<ol>
<li>Black tea</li>
<li>Green tea</li>
</ol>
</li>
<li>Milk</li>
</ol>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Nested Ordered List

HTML Description List: 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.Please refer to the How to add description list of an element using HTML? article for further details.

Syntax:

<dl> Contents... </dl>

Example: This example describes the HTML Description List.




<!DOCTYPE html>
<html>
<body>
<h2>A Description List</h2>
<dl>
<dt>Coffee</dt>
<dd>- 500 gms</dd>
<dt>Milk</dt>
<dd>- 1 ltr Tetra Pack</dd>
</dl>
</body>
</html>

Output:

Explain various types of lists that can be created in HTML giving suitable example

Description List

Supported Browser:

  • Google Chrome 94.0 & above
  • Microsoft Edge 93.0
  • Firefox 92.0 & above
  • Opera 78.0
  • Safari 14.1
  • IE 11.0

Explain various types of lists that can be created in HTML giving suitable example




Article Tags :
HTML
Technical Scripter
Web Technologies
HTML-Basics
Practice Tags :
HTML

HTML Lists

❮ Previous Next ❯

HTML lists allow web developers to group a set of related items in lists.


Example

An unordered HTML list:

  • Item
  • Item
  • Item
  • Item

An ordered HTML list:

  1. First item
  2. Second item
  3. Third item
  4. Fourth item
Try it Yourself »

HTML Lists

HTML Lists are used to specify lists of information. All lists may contain one or more list elements. There are three different types of HTML lists:

  1. Ordered List or Numbered List (ol)
  2. Unordered List or Bulleted List (ul)
  3. Description List or Definition List (dl)

Note: We can create a list inside another list, which will be termed as nested List.


1. Unordered Lists or Bullet Lists:

An unordered list is formed with the element UL and contains at least one list element LI. Use the

    tags to define the start and end of an unordered list. A number of list items (li elements) will go within the ul tags.

    List Item -

  • some item
  • : Add the text for each item in between some
  • and
  • tags. Each list item must have its own li tags.

    You May Also Like

    Features of HTML
    Structure of HTML Document
    HTML Formatting Tags
    Different Types of Lists in HTML

    Bullet Type

      : By default a browser will show a round bullet. This can be changed by using the type attribute of the ul tag, which will change the bullet type for the entire list.


      Example:




      • Coffee

      • Milk




      The Output is as follows:

      • Coffee
      • Milk

      10 Lists

      Contents

      1. Introduction to lists
      2. Unordered lists (UL), ordered lists (OL), and list items (LI)
      3. Definition lists: the DL, DT, and DD elements
        1. Visual rendering of lists
      4. The DIR and MENU elements