Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

P and div tags

Status
Not open for further replies.

amiw

Programmer
Apr 1, 2003
113
GB
I'm not sure whether to put the p element outside or inside the div tag?
What should be the considerations?

<div class="dummyclass">
<p>
dummy text
</p>
</div>

or

<p>
<div class="dummyclass">
dummy text
</div>
</p>

thanks
 
Second code is incorrect, since <p> tag cannot contain other block elements, which <div> is. Therefore, I assume your first code should be ok. However, it is hard to say without knowing what you're trying to do. First code is at least valid, while the second one is not.
 
<p> is short for paragraph. A <p> should be used to enclose each paragraph of text.

<div> is short for division. If you divide your document into logical sections, each division should be marked up as a <div>. A <div> can thus enclose one or more paragraphs (or other block-level elements), a paragraph can't enclose a <div>.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top