Proper way to make HTML nested list?

前端 未结 7 1253
执念已碎
执念已碎 2020-11-22 04:05

The W3 docs have a nested list example prefixed by DEPRECATED EXAMPLE:, but they never corrected it with a non-deprecated example, nor explained exactly what is

相关标签:
7条回答
  • 2020-11-22 04:43

    Have you thought about using the TAG "dt" instead of "ul" for nesting lists? It's inherit style and structure allow you to have a title per section and it automatically tabulates the content that goes inside.

    <dl>
      <dt>Coffee</dt>
        <dd>Black hot drink</dd>
      <dt>Milk</dt>
        <dd>White cold drink</dd>
    </dl>
    

    VS

    <ul>
       <li>Choice A</li>
       <li>Choice B
          <ul>
             <li>Sub 1</li>
             <li>Sub 2</li>
          </ul>
       </li>
    </ul>
    
    0 讨论(0)
提交回复
热议问题