[thelist] css class vs id (div or p )

Simon Dell simondl at epic.co.uk
Fri May 10 04:10:01 CDT 2002


At 09:48 10/05/02 +0100, you wrote:

>when and why would you use either <div> and <p> what are the differences?
>
>Andrew

A <p> is to mark up a paragraph of text.
A <div> is to mark up a division of content within the page.

Simple, isn't it?

Some points:
- You can't nest paragraphs (i'm pretty sure..) because having a paragraph
within a paragraph doesn't make sense. You don't get it in written language
so you shouldn't get it in HTML. You can nest <divs> (except in NN4 because
it's useless..) because it's perfectly possible to nest any number of
divisions within divisions.
- Paragraphs are like headings in that they describe the structural layout
of the content of the document. (i hope i got that right!)

Whilst in practice you can use them to do very similar things, especially
if you use CSS-P to position them, they have different meanings and
browsers are at some liberty to treat them differently. A text-only or a
speech controlled or a pda-centered browser may allow for navigation
through a page using the headings and paragraphs it contains rather than
vertically scrolling through it all as most MAC/'Nix/PC browsers do today.
The html specification is designed to allow for these different control
methods in the same way as it is trying to separate content from
presentation, so that the content can remain intact, viewable and navigable
as the systems used to present it evolve.

HTH
Simon Dell




More information about the thelist mailing list