Home  >  Article  >  Web Front-end  >  How to use list in html

How to use list in html

下次还敢
下次还敢Original
2024-04-27 21:21:18517browse

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.

How to use list in html

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:

  • Unordered list (
      ): Used to display unsorted items, usually marked with dots or dashes.
    • Ordered list (
        ): Used to display sorted items, usually marked with numbers or letters.

    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

    • ##type: Specifies the list type, which can be "disc" (dot), "circle" (circle) or "square" (square), etc.
    • start: Specifies the starting value of the ordered list.

    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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn