Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

P versus DIV

0 views
Skip to first unread message

David C. Holley

unread,
May 4, 2004, 8:01:40 AM5/4/04
to
Can anyone give me a really good explanation of the difference between
<p> and <div>?

PeterMcC

unread,
May 4, 2004, 12:02:26 PM5/4/04
to
David C. Holley wrote in
<eo9wZ%23cMEH...@TK2MSFTNGP11.phx.gbl>

> Can anyone give me a really good explanation of the difference between
> <p> and <div>?

They are both container elements - other than that there's hardly any
similarity between them.

<p> Indicates the start of a new paragraph.

<div> Indicates the start of a generic block-level container for which the
styling of the contents can be defined by the author - a div can contain
other elements including divs (or paragraphs).

--
PeterMcC
If you feel that any of the above is incorrect,
inappropriate or offensive in any way,
please ignore it and accept my apologies.

PeterMcC

unread,
May 8, 2004, 7:10:26 AM5/8/04
to
RoboSchro wrote in
<9E3BD1B4-6CCF-461B...@microsoft.com>

[For reference - OP was "Can anyone give me a really good explanation of the
difference between <p> and <div>?"]

> Visually, they are interchangeable.

I don't think that's entirely the case - unless the <div> were set to
emulate the same appearance as <p>. Mind you, that's rather self-evident in
that anything that is successfully made to emulate something else will be
interchangeable with it :)

> Structurally, though, a <p> means paragraph, while a <div> is generic
> and has no particular meaning. Paragraph, header, and listitem tags
> should be used to contain all your text, where possible. This way any
> browser or other program that's reading your html will find it
> possible to interpret your file correctly.

The OP presented a wide question that would be difficult to answer without a
lengthy explanation but I think that the brevity used above may result in
some misunderstanding.

José Jeria

unread,
May 8, 2004, 7:23:56 AM5/8/04
to
RoboSchro wrote:

> Visually, they are interchangeable.


> Structurally, though, a <p> means paragraph, while a <div> is generic and has no particular meaning. Paragraph, header, and listitem tags should be used to contain all your text, where possible. This way any browser or other program that's reading your html will find it possible to interpret your file correctly.

Also <p> cannot contains other block elements, <div> can. <p> has also a default
margin, which <div>:s dont have

Little Dave

unread,
May 10, 2004, 1:37:21 PM5/10/04
to
RoboSchro wrote:

> while a <div> is generic and has no particular meaning.

I disagree a bit. <div> is a division of the page. A <div> without an ID
*is* meaningless but if one were to write:


<div id="nav">
<a href="home.html">Home</a>
<a href="page1.html">Page 1</a>
<a href="page2.html">Page 1</a>
<a href="page3.html">Page 1</a>
</div>
<div id="pageContent">
<p>
Hello, this is a paragraph which is related to the ID of the
containing div. e.g. One would assume that text written here would be
the main content/body text of the page.
</p>
<p>
It is also logical to assume that HTML code contained within the
nav div would only be navigational code i.e. links for a navigation bar.
</p>
</div>


..then it would be completely structural.

EXTRA NUGGET:
However, spans are a little bit unstructured, as they are not *really*
relevant to the meaning of the code:
....
<p>
Hello, my name is <span class="important">David</span>. I write <span
class="important">semantic</span> code.
</p>
....

..But I still use them in moderation.

Regards

Dave


--
Little Dave
http://www.daveholloway.co.uk
Everyone feel free to add me to your instant messengers:
MSN: daveho...@spamcop.net, YAHOO: daveho...@yahoo.com, ICQ: 104452444

0 new messages