In article
<499d62f5-5bc6-4c30-9cd7-5ec62a2248b0@d4 5g2000hsc.googl egroups.com>,
bgold12 <bgold12@gmail. comwrote:
Are there any non-semantic (i.e. actual) differences between the <p>
tag and the <divtag?
There are the ways they are regarded by browsers partly because of their
meaning or lack of. In English at least, paragraphs, which are sets of
sentences that have some common thought are traditionally typeset with
some margin at top and bottom. These styles are defaulted to, not always
exactly the same for each browser but they all try to capture the
tradition.
In other words, there are non semantic things about them that
distinguish them. These arise because of the semantic intentions (which
is nothing in the case of the div). Browsers set these defaults so that
readers can see they are paragraphs...
You can, course, override the style defaults.
And there are other differences too in what you can and cannot have as
their children. And these flow from meaning in most cases. Let's stay
with 4.01 Strict.
You can have
<div>
<div>text</div>
</div>
and
<div>
<p>text</p>
</div>
but not
<p>
<div>text</div>
</p>
or
<p>
<p>text</p>
</p>
You can't have the last because it has no meaning. A paragraph within a
paragraph? Well, maybe there could be some sense in it but it is a bit
of a stretch.
Why you can't have the one before that is complicated, the p
element/4.01 HTML makers were perhaps a little over-religious about
this.
"The P element represents a paragraph. It cannot contain block-level
elements (including P itself)."
But that is because the normally inline image crept into the p element
and then sneakily changed to being a block box before it could be kicked
right out of there. <g>
You can't (in a special sense of can't) have the eminently reasonable
<p>...
<ul>
<li>item</li>
</ul>
</p>
Absurd of course, but that is how it is. Perhaps you can just be
reasonable and let validators scream?
I better stop. People love talking about these things and you will get
more for sure.
Comment