HTML05: List
To display a list of items on a web site a <li> tag is
used. For example, to display a list of five fruits:
Code snippet
|
Output
|
<li>Apple</li>
<li>Orange</li>
<li>Grapes</li>
<li>Banana</li>
<li>Pear</li>
|
·
Apple
·
Orange
·
Grapes
·
Banana
·
Pear
|
There are two types of list, an ordered
list or unordered list. An ordered list displays the number in front the each
items in a list. Unordered list only display bullet in front of each items. By
default, a list is unordered and uses disc bullet as shown in example above.
Ordered list uses <ol> tag
and unordered list start with <ul>
Below is an example for ordered list
|
|
Code snippet
|
Output
|
<ol>
<li>Apple</li>
<li>Orange</li>
<li>Grapes</li>
<li>Banana</li>
<li>Pear</li>
</ol>
|
1. Apple
2. Orange
3. Grapes
4. Banana
5. Pear
|
Below is an example for unordered list:
|
|
Code Snippet
|
Output
|
<ul>
<li>Apple</li>
<li>Orange</li>
<li>Grapes</li>
<li>Banana</li>
<li>Pear</li>
</ul>
|
·
Apple
·
Orange
·
Grapes
·
Banana
·
Pear
|
A list can be written inside of
another list. this is known as nested ist. Example below shows the example for
nested list.
Code Snippet
|
Output
|
<ol>
<li>Apple
<ul>
<li>Apple
Pie</li>
<li>Apple
Juice</li>
</ul>
</li>
<li>Grapes
<ul>
<li>Grape
Jam</li>
<li>Grape
Juice</li>
<li>Grape
Salad</li>
</ul>
</li>
<li>Banana</li>
<li>Pear</li>
</ol>
|
1.
Apple
o Apple Pie
o Apple Juice
2.
Grapes
o Grape Jam
o Grape Juice
o Grape Salad
3.
Banana
4.
Pear
|
Changing the bullet of unordered list can be achieved using
the type attribute. Types of bullets available are disc, circle and square.
Code Snippet
|
Output
|
<ul type = "square">
<li>Apple</li>
<li>Grape</li>
<li>Banana</li>
<li>Pear</li>
</ul>
|
|
<ul type = "circle">
<li>Apple</li>
<li>Grape</li>
<li>Banana</li>
<li>Pear</li>
</ul>
|
|
Ordered list also has several types that display different
numbering format. To change the type of an ordered list numbering
Code Snippet
|
Output
|
<ol type = "a">
<li>Apple</li>
<li>Grape</li>
<li>Banana</li>
<li>Pear</li>
</ol>
|
a.
Apple
b.
Grape
c.
Banana
d.
Pear
|
<ol type = "i">
<li>Apple</li>
<li>Grape</li>
<li>Banana</li>
<li>Pear</li>
</ol>
|
i.
Apple
ii.
Grape
iii.
Banana
iv.
Pear
|
Comments
Post a Comment