Home > Article > Web Front-end > How to use list in html
A list is an element in HTML used to display a sequence of items. There are two types of unordered lists and ordered lists, marked with dots or numbers/letters respectively. The syntax is
and
, and the list type, starting value, etc. can be specified through attributes. Lists can be nested, creating sublists within list items.
Usage of lists in HTML
What is a list?
A list is an element in HTML used to display a series of related or ordered items.
Type
There are two types of lists in HTML:
Syntax
The syntax for a list is as follows:
<code class="html"><ul> <li>项目 1</li> <li>项目 2</li> <li>项目 3</li> </ul></code>
Attributes
Nested lists
Lists can be nested, that is, sublists are created within list items:<code class="html"><ul> <li>项目 1 <ul> <li>子项目 1</li> <li>子项目 2</li> </ul> </li> <li>项目 2</li> </ul></code>
Example
Unordered list:
<code class="html"><ul> <li>苹果</li> <li>香蕉</li> <li>橙子</li> </ul></code>
Ordered list:
<code class="html"><ol> <li>星期一</li> <li>星期二</li> <li>星期三</li> </ol></code>
Nested list:
<code class="html"><ul> <li>动物 <ul> <li>狗</li> <li>猫</li> </ul> </li> <li>水果</li> </ul></code>
The above is the detailed content of How to use list in html. For more information, please follow other related articles on the PHP Chinese website!