Lists


Lists

A list is a collection of short pieces of information, such as people's names, that is normally written or printed with a single item on each line and organised in a way that makes finding a specific item easy.

There are three ways of displaying the contents of lists. There can be one or more elements in a list and they are useful to group similar items together.

  • Unordered List - < ul >

    This is a list of related items having no order or sequence to follow. They use bullet points to list the items. < li > tag is used to list the elements.
  • Ordered List -< ol>

    When we need to follow a sequence we can use an ordered list. It is also known as a numbered list.
  • Definition List -< dl >

    It is also known as a description list. The list items are listed like a dictionary or an encyclopedia. It can be used when we want to display a glossary, list of terms, or name-value pairs. The < dl > tag is the start of the list, < dt > tag holds the name(term) and < dd > tag is for the value (term definition).
  • Nested List in HTML

    A nested list is a list that is contained within another list. If you want a bullet list inside a numbered list, you'll need to create a nested list.

Example No.1:

<html> <body> <h2>Knowledge2life</h2> <ul> <li>Website</li> <li>Learning</li> <li>Best</li> </ul> </body> </html>

OUTPUT:

  • Website
  • Learning
  • Best

Example No.2:

<html> <body> <h2>Knowledge2life</h2> <dl id="dddd"> <dt>Knowledge2life</dt> <dd>- Website</dd> <dt>Country</dt> <dd>- India</dd> </dl> </body> </html>

OUTPUT:

Knowledge2life
- Website
Country
- India