I want to display a division which contains some elements in it in between some text. so i thought to use div inside the para tag in html. but i can't get the thing worked. is there any appropriate way to do this?
Asked
Active
Viewed 46 times
-1
-
1Duplicate: http://stackoverflow.com/questions/8397852/why-p-tag-cant-contain-div-tag-inside-it – jianweichuah Dec 19 '15 at 07:20
-
no, as per w3c specification p are allowed only inside division. since both are block elements. – yjs Dec 19 '15 at 07:20
-
just use a div with some margins instead of a p. – Mr Lister Dec 19 '15 at 07:26
-
can you please elaborate your suggestion @MrLister – Pradeepkumar Guruswamy Dec 19 '15 at 07:29
-
1You should show some code first and then I can tell you what the p needs to be replaced by exactly. – Mr Lister Dec 19 '15 at 07:33
-
cool, i made a mistake of understanding, now i got working with my expectation. – Pradeepkumar Guruswamy Dec 19 '15 at 07:45
1 Answers
1
No, the <p>
tag is only permitted to use "phrasing content" as specified by W3C here under "Permitted contents": http://www.w3.org/TR/html-markup/p.html
Phrasing contents are things like <a>
, <em>
, <strong>
, etc. and don't include <div>
as specified here under "Phrasing elements": http://www.w3.org/TR/html-markup/common-models.html#common.elem.phrasing
And normal character data specified here: http://www.w3.org/TR/html-markup/syntax.html#normal-character-data
If you want elements in between your text just break it up into two separate <p>
tags, put whatever between it, and style them with CSS to make them look how you want.

Sam
- 1,115
- 1
- 8
- 23