Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

paragraph tag does not enclose block elements

Tags:

html

css

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 element. 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>
like image 885
JoJo Avatar asked Nov 25 '25 07:11

JoJo


2 Answers

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).

like image 149
Emmett Avatar answered Nov 27 '25 20:11

Emmett


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

like image 23
Jonathan Wood Avatar answered Nov 27 '25 20:11

Jonathan Wood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!