Is it syntactically and semantically correct to nest <div> or any other block level element inside the <p> tag. I am talking about HTML4 Transitional DTD.
If not then is it OK to instead use <span style="display: block"> instead?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Syntactically, a
divinside apis invalid in all standards of HTML. Moreover, when using a conforming HTML parser, it is impossible to place a<div>element inside a<p>in the DOM because the opening<div>tag will automatically close the<p>element.Semantically, the correct choice depends on the content that you are marking up. You will need to show at least a sample full paragraph and possibly the content surrounding it to be sure of providing sufficient information for the correct semantic mark-up to be determined.
However, given that both
<div>and<span>are semantics free, and that CSS in no way can ever change that, if you are certain that the contents of the<p>tag truly form a paragraph, and that<span style="display: block">gets you the presentational effect that you are seeking, then that is valid HTML and would be a wholly appropriate solution.