How can I put DIV in P?
How can I put div in paragraph? I changed the display to inline, but the browser divide the base paragraph to two element, and div will not member of paragraph.
Solution 1:
form the w3 site:
The P element represents a paragraph. It cannot contain block-level elements (including P itself).
Solution 2:
no you cannot nest anything other than an inline element in a <p>
if you want the code to validate
from the property def:
<!ELEMENT P - O (%inline;)* -- paragraph -->
I know it's hard to understand those recs at times, but the bit in brackets means the <p>
can only contain inline
elements
you can (and should) use a <span>
inside a <p>
and if required you could change it's CSS display property to block
or inline-block
and that would be perfectly valid, as CSS properties do not change the actual definitions of an element.. in your case it sounds like you need an inline element so just use a <span>
Solution 3:
Make a span, set it's style to a block.
<p>
paragraph text
<span style="display: block;">Span stuff</span>
</p>