There are three types of lists in HTML −
- unordered list <ul>
This list has bullets list items with no specific order.
- ordered list <ol>
This list is used for ordered list items
- definition list <dl>
This list is used to display definitions for terms.
We can nest these lists and style them as desired. CSS property list-style helps us style the list items.
Syntax
The syntax of HTML lists is as follows −
<type of list> <li></li> </type of list>
The following examples illustrate HTML lists −
Example
<!DOCTYPE html>
<html>
<head>
<style>
ul {
background-color: papayawhip;
list-style-type: square;
font-style: italic;
}
ol {
background-color: azure;
}
</style>
</head>
<body>
<ol>
<li>demo1</li>
<li>
demo 2
<ul>
<li>demo a</li>
<li>demo b</li>
</ul>
</li>
<li>demo 3</li>
</ol>
</body>
</html>Output
This gives the following output −

Example
<!DOCTYPE html>
<html>
<head>
<style>
dt {
font-weight: bold;
font-style: italic;
}
dd {
border: thin dotted;
}
</style>
</head>
<body>
<h2>Programming Languages and Databases</h2>
<dl>
<dt>Java</dt>
<dd>A programming language developed by James Gosling.</dd>
<dt>C++</dt>
<dd>A programming language developed by Bjarne Stroustrup.</dd>
<dt>MySQL</dt>
<dd>MySQL is an open-source relational database management system.</dd>
</dl>
</body>
</html>Output
This gives the following output −
