一切都在< ul>必须包装在< li>中? [英] Does everything inside a <ul> have to be wrapped in an <li>?

查看:131
本文介绍了一切都在< ul>必须包装在< li>中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些有关HTML中嵌套列表的指导。

I need some guidance about nested lists in HTML.

我有一个布局,我希望像下面那样构建。嵌套未被< li> 包装的元素是否可怕?我确信它违反了标准,但不知道它有什么不良影响。

I have a layout that I would like to be built like below. Is it a terrible thing to nest an element not wrapped by an <li>? I'm fairly sure that it is against standards, but don't know what ill effect it has.

<ul>
  <li>
    <h1>header 1</h1>
    <li>
       <ul>
         <li>nested</li>
         <li>list</li>
       </ul>
    </li>
  </li>
  <li>
    <h1>header 2</h1>
    <li>
       <ul>
         <li>nested</li>
         <li>list</li>
       </ul>
    </li>
  </li>
</ul>


推荐答案

LI 是允许作为 UL 的子元素的唯一元素。以下是 UL $ b

LI is the only element allowed as child elements of UL. Here’s a snippet of the UL element definition:


<!ELEMENT UL - - (LI)+                 -- unordered list -->


另外:

And:


这两种类型的列表都由由 LI 元素定义的列表项序列组成(其结束标记可以省略)。

Both types of lists are made up of sequences of list items defined by the LI element (whose end tag may be omitted).

这篇关于一切都在&lt; ul&gt;必须包装在&lt; li&gt;中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆