开发者

paragraph tag does not enclose block elements

How do I place block elements in the HTML paragraph tag? When I attempt to do that, Firebug's HTML tab shows that the paragraph does not enclose the block e开发者_运维技巧lement. Furthermore, any CSS applied to the paragraph does not apply to the child block element.

This code:

<p>
 <ol>
  <li>foo</li>
  <li>bar</li>
 </ol>
</p>

p {
 line-height: 2em;
}

Becomes rendered as:

<p></p>
<ol>
 <li>foo</li>
 <li>bar</li>
</ol>


From http://www.w3.org/TR/html401/struct/text.html:

The P element represents a paragraph. It cannot contain block-level elements (including P itself).


List tags are not supposed to be enclosed in a paragraph tag. What are you trying to do?


It sounds like you should be using a <div> instead of a <p>


Paragraphs are meant to hold inline elements not block elements. In fact, take a peek at this...

http://bytes.com/topic/html-css/answers/153770-acceptable-put-ul-inside-paragraph.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜