when to use UL or OL in html?

前端 未结 12 1992
陌清茗
陌清茗 2020-12-05 03:58

Seems interchangable?

相关标签:
12条回答
  • 2020-12-05 04:23

    I think it's a sematic issue, as the numbering/bullet points can be changed by CSS.

    Ordered lists should be things like instructions, or any sequential information.

    Unordered lists should be everything else.

    0 讨论(0)
  • 2020-12-05 04:24

    Use OL when you're listing steps that need to be done in a certain order. Use UL when you're listing items in no particular order of importance.

    0 讨论(0)
  • 2020-12-05 04:26

    One is ordered list (OL), it is for things that have a defined and distinct order. There is a reason behind why they are organized.

    The other (UL) is unordered list, which is just a collection of things in no specified order. Their organization is trivial.

    0 讨论(0)
  • 2020-12-05 04:27

    In some cases (specifically used by Screen Readers for people with special needs) you may want to have ordered list but not have numbers associated with them due to visual design. Ex. when you've let's say instructions on a page to fill up a form and want screen readers to take advantage of ordered items in the instructions then it will be useful. For all visual purposes they can be made to look exactly the same through CSS. It's the (non-visual, but helpful to screen reader) semantics that are different and at times useful.

    0 讨论(0)
  • 2020-12-05 04:29

    OL:

    1. List item 1
    2. List item 2

    UL:

    • List item 1
    • List item 2

    OL is ordered list, UL is unordered list

    0 讨论(0)
  • 2020-12-05 04:29

    ol = means ordered list. Use when you want to list and number things. ul = means unordered list. Use when you want to list but not number them.

    I think OL should have been called NL = numbered list. Why? Because UL can also have an order but not be numbered.

    0 讨论(0)
提交回复
热议问题