简体   繁体   English

我应该使用 <div> 代替 <p> 当它包含一个列表( <ul> )?

[英]Should I use a <div> instead of <p> when it contains a list (<ul>)?

On this snippet: 在这个片段上:

<p>
  <ul>
    <li>A</li>
    <li>B</li>
  </ul>
</p>

IntelliJ 10.5 warns that the closing </p> tag "matches nothing`. IntelliJ 10.5警告关闭</p>标签“不匹配”。

I see that <p> is only supposed to contain " Phrasing content ". 我看到<p>只应该包含“ Phrasing内容 ”。 So, should I replace the <p> with a <div> ? 那么,我应该用<div>替换<p> <div>吗?

Yes. 是。 <p> isn't supposed to contain lists, it's intended for inline content. <p>不应包含列表,它用于内联内容。 <div> is right here if you're just looking to wrap the list in an element. 如果您只想将列表包装在元素中, <div>就在这里。

<div>
  <ul>
    <li>A</li>
    <li>B</li>
  </ul>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM