HTML Tags – UnOrdered List


What is an Unordered List in HTML ?

It is a collection of related items which have no special order or sequence.

Unordered List do not need to display items in any particular order.

What are the attributes in <ul> tag ?

There are 4 types of attributes in <ul> tag.

1. disc

2. circle

3. square

4. none

HTML beginners tutorial !!!

Click to Learn More about – HTML Tutorial for beginners

1. Simple Unordered list

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
        </head>
        <body>
                <ul>
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :

2. Nested Unordered list

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
        </head>
        <body>
                <ul>
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <ul>
                                <li>Apple</li>
                                <li>Orange</li>
                                <ul>
                                        <li>Red</li>
                                        <li>Green</li>
                                        <li>Black</li>
                                        <li>White</li>
                                </ul>
                                <li>Papaya</li>
                                <li>Banana</li>
                        </ul>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :


3. Unordered list with inline style.

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
        </head>
        <body>
                <ul style="color:blue">
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :

4. Unordered list with class

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
                <style>
                .ul1{
                        color:red;
                }
                </style>
        </head>
        <body>
                <ul class="ul1">
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :

5. Unordered list with id

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
                <style>
                #ul1{
                        color:green;
                }
                </style>
        </head>
        <body>
                <ul id="ul1">
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :


6. Unordered list with type disc

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
                <style>
                #ul1{
                        color:green;
                }
                </style>
        </head>
        <body>
                <ul id="ul1" type="disc">
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :


7. Unordered list with type circle

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
                <style>
                #ul1{
                        color:green;
                }
                </style>
        </head>
        <body>
                <ul id="ul1" type="circle">
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :


8. Unordered list with type square

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
                <style>
                #ul1{
                        color:green;
                }
                </style>
        </head>
        <body>
                <ul id="ul1" type="square">
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :

9. Unordered list with type none

Example :

<!DOCTYPE html>
<html>
        <head>
                <title>List tag</title>
                <style>
                #ul1{
                        color:green;
                }
                </style>
        </head>
        <body>
                <ul id="ul1" type="none">
                        <li>MKGandhi</li>
                        <li>AbdulKalaam</li>
                        <li>Tendulkar</li>
                        <li>RahulDravid</li>
                </ul>
        </body>
        </html>

Output :

<ul> Tag Attributes

HTML <ul> tag support following specific attributes.

SnoAttributesValueDescription
1compactcompactSpecifies the list should be render compact view.
2typedisc
square
circle
Specifies the style of the bullet.

Global Attributes

HTML <ul> tag support following global attributes.

SnoAttributesValueDescription
1idunique_nameDeclared unique id for an element.
2classclass_nameDeclared one or more classnames for an element.
3stylestylesCSS inline styles specify an element.
4titletitleSpecify extra details of element contain, this will display as a “tooltip” for an elements.

Event Attributes

HTML <ul> tag support following event attributes.

SnoAttributesValueDescription
1onfocusscriptelement gets focus on object when script tobe run.
2onblurscriptelement lose the focus on object when scrip tobe run.
3onabortscriptelement gets aborted on object when script tobe run.
4onchangescriptelement gets anytime change on object when script tobe run.
5onbeforeunloadscriptelement gets unloaded on object when scrip tobe run.
6onclickscriptclicked on object when script tobe run.
7ondblclickscriptdouble click on object when script tobe run.
8onkeydownscriptkey is pressed when script tobe run.
9onkeypressscriptkey is pressed over element then released when script tobe run.
10onkeyupscriptkey is released over element when script tobe run.
11onmousedownscriptmouse button was pressed over an element when script tobe run.
12onmouseoutscriptmouse pointer release over an element when script tobe run.
13onmousemovescriptrun mouse pointer moved when script tobe run.
14onmouseoverscriptrun mouse pointer move over when script tobe run.
15onmouseupscriptmouse button is released when script tobe run.
16onresetscriptform has been reset when script tobe run.
17onselectscriptSelect some content when script tobe run.
18onsubmitscriptform has been submitted when script tobe run.
19onloadscriptobject has load when script tobe run.
20onchangescriptallow to change the object when script tobe run.
21onunloadscriptunload to the browser window when script tobe run.
22ondragscriptelement being dragged when script tobe run.
23ondragendscriptelement being stop dragged when script tobe run.
24ondragenterscriptelement being go target dragged when script tobe run.
25ondragleavescriptelement being leave to target dragged when script tobe run.
26ondragoverscriptelement being over to target dragged when script tobe run.
27ondragstartscriptelement being start dragged when script tobe run.
28ondropscriptelement being dropped when script tobe run.
29onerrorscriptelement error occurs when script tobe run.
30onmessagescriptelement message display when script tobe run.
31onerrorscriptelement error occurs when script tobe run.
32onmousewheelscriptmouse wheel will be rotate when script tobe run.
33onscrollscriptscrollbar is scroll when script tobe run.
34onresizescriptelement should be resize when script tobe run.
35onselectscriptall element content selected when script tobe run.
36onstoragescriptelement should be store in target when script tobe run.

Browser Compatibility

SnoBrowserSupport
1ChromeYes
2FirefoxYes
3EdgeYes
4OperaYes
5SafariYes
6Internet ExplorerYes