How to use list in html

下次还敢
Release: 2024-04-27 21:21:18
Original
522 people have browsed it

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>
    Copy after login

    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>
    Copy after login

    Example

    Unordered list:

    <code class="html"><ul>
      <li>苹果</li>
      <li>香蕉</li>
      <li>橙子</li>
    </ul></code>
    Copy after login

    Ordered list:

    <code class="html"><ol>
      <li>星期一</li>
      <li>星期二</li>
      <li>星期三</li>
    </ol></code>
    Copy after login

    Nested list:

    <code class="html"><ul>
      <li>动物
        <ul>
          <li>狗</li>
          <li>猫</li>
        </ul>
      </li>
      <li>水果</li>
    </ul></code>
    Copy after login

    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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!