by Dinesh Thakur Category: HTML

An Ordered list is one that is numbered and may also be used to indicate sequential form of information. <ol> and </ol> are opening and closing tags for an ordered list respectively. The code used for ordering the List as below:

<html>

<head><title>ordered list without numbers</title></head>
<body>
software testing methods
<ol> black box testing
white box testing
control structure testing
</ol>
</body>
</html>

We observe from above code that text is indented during the actual printing of the list. However, the listed items have not been printed on separate lines. HTML does not recognize line breaks, unless it is told by using <P> or <BR> tags. The list item tag <LI> is used to remove this problem. It can be noticed in the code as shown below:

<html>

<head><title>ordered list with numbers</title></head>
<body>
software testing methods
<ol>
<li> black box testing
<li> white box testing
<li> control structure testing
</ol>
</body>
</html>

When the browser encounters the tag <LI> for each item, it starts a new line, indents and adds a number. Thus we get the output as seen in the above figure1.15. Ordering is typically rendered by a numbering scheme, using Arabic numbers, letters or Roman numerals.

By default numbered lists use Arabic numerals (1, 2, 3, 4). So by writing <OL type = a> instead of just <OL> we have overridden the default & created a numbered list which uses alphabets for numbering. The code shows the OL listing as:

<html>

<head><title>ordered list with numbers</title></head>
<body>
software testing methods
<oltype= a>
<li> black box testing
<li> white box testing
<li> control structure testing
</ol>
</body>
</html>

The values & Styles for the type attribute are given below:

Value              Style                            Example

1 (default)         Arabic                          1, 2, 3, 4, ....

a                      Lower case alpha         a, b, c, d, ....

A                     Uppercase alpha           A, B, C, D....

I                       Uppercase Roman        I, II, III, .....

i                       Lower case Roman       i, ii, iii,.......

The start attribute: This attribute is used to override default list numbering when a list is divided into multiple parts. The use of start attribute can be shown in the code as.

<htm>

<head><title>ordered list with numbers</title></head>
<body> impact printers
<ol>
<li> dot matrix
<li> chain printer
<li> drum printer
<li> ink jet printer
</ol> <p>non-impact printers
</p> <olstart=5>
<li> laser printer
<li> electrostatic printer
<li> wax printer
</ol>
</body>
</html>

The use of <OL start = 5> instead of <OL> makes the browser understand that the numbering of the second list is to start from 5 & not 1 (The default value)

Nested Lists

A nested list is a list within a list that can extend up to several levels. One of the most common places where we can see a nested list is in the contents of a book. To create a nested list a new set of ordered list tags is to be included within the current list tags. The code shows the insertion of a new list within the original list i.e. (nested list).

<html>

<head><title>nested list </title></head>
<body> type of printers
<oltype=a>
<li> impact printers
<oltype=1>
<li>character printers
<oltype=i>
<li> dot matrix
<l1> ink jet printer
<l1> letter quality
</ol> <li>line printers
<oltype=i>
<li>chain printers
<li>drum printers
</ol> </ol>
<li>non-impact printers
<ol type= a>
<li> laser printer
<li> electrostatic printer
<li> wax printer
<li> ink jet printer
</ol> </ol>
</body>
</html>






About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.