: To or not to ? I recently had a debate with a colleague who claimed that a <div> tag should be used over a <p> tag when formatting paragraphs. The case against the use of <p>
I recently had a debate with a colleague who claimed that a <div> tag should be used over a <p> tag when formatting paragraphs.
The case against the use of <p> is that it produces irregular spacing across browsers and it is likely to become obsolete like the <b> tag.
Is this opinion of the <p> tag shared by the community?
More posts by @Jamie184
2 Comments
Sorted by latest first Latest Oldest Best
<p> and <div> are not meant for the same purpose, as they have a different semantical meaning:
<p> is for paragraph,
<div> is to "offer a generic
mechanism for adding structure to
documents", as stated in the div
HTML spec from W3C
<p> may not be deprecated in the future as it still is present in XHTML and HTML 5.
Both tags have different graphical rendering. A <p> has a top and a bottom margin of 1em, whereas a <div> has no margin at all. But this point is secondary as it may be overridden by CSS.
Also, note this difference: while both tags are of type "block", only <div> can contain other block elements. Thus:
<p><p> bla </p></p> is wrong, while
<div><div> bla </div></div> is ok
The important point to remember is both are valid and used tags, but not for the same purpose.
divs and ps are for completely different purposes. p is for paragraphs, div is for sectional divisions. One is for text formatting, the other is for page structure. It is semantically incorrect to use div in place of p.
And the reason the use of b is discouraged is because it's a presentation tag. It has no semantic meaning. Both p and div have their own unique semantic meanings. p will never be obsolete as long as people still format text into paragraphs.
Your colleague doesn't appear to be familiar with the principle of separation of content and presentation. Otherwise, he would know why b is abhorred and that presentation issues like text spacing ought to be defined in CSS, not your HTML.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.