Html List | How to Create Nested List in Html | List without Bullets

Html List
Html List


Overview

Html list uses to combine a set of related words or content in a list. Html has three types of list order list, unorder list and description list <li> tag use to define list content.   

Html list

Html list uses to define related words or content in a list. There are three types of list order list, unorder list, and description list. List content are define by using <li> tag. Order list define by using <ol> tag. Content will show with a number. Let look at how to declare an order list.

Code:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>HTML Order List List</title>

</head>

<body>

   <ol>

       <li>Product 1</li>

       <li>Product 2</li>

       <li>Product 3</li>

       <li>Product 4</li>

       <li>Product 5</li>

   </ol>

</body>

</html>

Result

Html order List Example
Html order List Example


Unorder list are defined by using <ul> tag. List content goes in <li> tag. Content will show in bulleted form. Lets see the code.

Code:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>HTML Unorder list</title>

</head>

<body>

    <ul>

       <li>Product 1</li>

       <li>Product 2</li>

       <li>Product 3</li>

       <li>Product 4</li>

       <li>Product 5</li>

   </ul>

</body>

</html>

Result:

Html Unorder List Example
Html Unorder List Example


Description list define by <dl> tag. It has two sub tag like <dt> and <dd> tag. <dt> use for title of description term while <dd> use for term description. Let look example of description list.

Code:

<!DOCTYPE html>

<html lang="en">

<head>

    <title>Html Description List</title>

</head>

<body>

    <dl>

        <dt>Item Title 1</dt>

        <dd>Item 1 description Point 1</dd>

        <dd>Item 1 description Point 2</dd>

        <dd>Item 1 description Point 3</dd>

        <dt>Item Title 2</dt>

        <dd>Item 1 description Point 1</dd>

        <dd>Item 1 description Point 2</dd>

        <dd>Item 1 description Point 3</dd>

        <dt>Item Title 3</dt>

        <dd>Item 1 description Point 1</dd>

        <dd>Item 1 description Point 2</dd>

        <dd>Item 1 description Point 3</dd>

        <dt>Item Title 4</dt>

        <dd>Item 1 description Point 1</dd>

        <dd>Item 1 description Point 2</dd>

        <dd>Item 1 description Point 3</dd>

        <dt>Item Title 5</dt>

        <dd>Item 1 description Point 1</dd>

        <dd>Item 1 description Point 2</dd>

        <dd>Item 1 description Point 3</dd>

    </dl>

</body>

</html>

Result:

Html Description  List Example
Html Description  List Example


First description title show. And under title description show. A little bit of Left space use in the title description. As you can see in fig.   

Html list style

Html list can be make stylish by using CSS. For example.

Code:

ol{

            width30%;

            list-style-typedecimal-leading-zero;

            letter-spacing1px;

 }

list-style-typedecimal-leading-zero;

This property used to how to list show like in number or roman. By default order list set decimal. Which start from 1,2,3, and so on. By using list-style-typedecimal-leading-zero; property list show like 01,02,03, and so on.  list-style-typeupper-roman list show with roman. When we set this property none then no number shows simple list show

Example,

Style:

ol{

            width30%;

            list-style-typeupper-roman;

            letter-spacing1px;

        }

        li{

            border2px solid #eee;

            margin4px;

            padding5px;

        }

        li:hover{

            background-color#26A65B;

            colorwhite;

            font-weightbold;

        }

When we apply this style to above mention order list code then the output will like this.

Result:

Html Order List Style Example
Html Order List Style Example

When we apply the same style on unorder list and one the thing we will list-style-typecircle;

Then the output will be like this.

Result:

Html Unorder List Style Example
Html Unorder List Style Example


We can style description list like this,

Style:

<style>

        dl{

            width40%;

            letter-spacing1px;

        }

        dt{

            font-weightbold;

        }

        dd{

            font-styleitalic;

        }

        dt,dd{

            border2px solid #eee;

            padding5px;

            margin-top4px;

            margin-bottom2px;

        }

    </style>

Result:

 

Html Description List Style Example
Html Description List Style Example

Bullet list in HTML

By default, order and unordered lists are bulleted. A description list is not bulleted.

Html list without bullets.

We can make list without bullets like this. list-style-typenone; when we use this property. Then list will show without number or bullets. For example,

Code:

<!DOCTYPE html>

<html lang="en">

<head>

    <title>HTML Unorder list</title>

    <style>

        ul{

            width30%;

            list-style-typenone;

            letter-spacing1px;

        }

        li{

            border2px solid #eee;

            margin4px;

            padding5px;

        }

        li:hover{

            background-color#26A65B;

            colorwhite;

            font-weightbold;

        }

    </style>

</head>

<body>

    <ul>

       <li>Product 1</li>

       <li>Product 2</li>

       <li>Product 3</li>

       <li>Product 4</li>

       <li>Product 5</li>

   </ul>

</body>

</html>

Result:

Html List without bullets Example
Html List without bullets Example


Nested list in html

we can use list within list. Let see the example,

Code:

<!DOCTYPE html>

<html lang="en">

  <head>

    <title>HTML Nested list</title>

    <style>

      ul {

        width30%;

        list-style-typenone;

        letter-spacing1px;

      }

      li {

        border2px solid #eee;

        padding5px;

        margin5px;

      }

      ul li ul{

          width90%;

      }

      ul li ul li{

          margin2px;

      }

    </style>

  </head>

  <body>

    <ul>

      <li>Product 1

        <ul>

          <li>Title</li>

          <li>Price</li>

        </ul>

      </li>

      <li>Product 2

        <ul>

          <li>Title</li>

          <li>Price</li>

        </ul>

      </li>

      <li>Product 3

        <ul>

          <li>Title</li>

          <li>Price</li>

        </ul>

      </li>

      <li>Product 4

        <ul>

          <li>Title</li>

          <li>Price</li>

        </ul>

      </li>

    </ul>

  </body>

</html>

Result:

 

Nested List Example
Nested List Example




0 Comments