In old HTML <p>
tag was simple separator, like <hr> or <br>
. It was changed into container <p></p>
. It does not make a sense to me. They could use <div></div>
as container, and leave <p>
as it was. Why W3C did this?
2 Answers
<p>
has never been a "simple separator", at least not in any standard version of HTML*. It is a container element -- a "paragraph", hence the "p" -- and always has been. It just happens that the end tag is optional, so a bunch of people (a*hem*) have been using it wrong all this time.
* It appears very early drafts of the HTML spec said that <p>
was a separator. But by the first public standard version (2.0), it was a container, and it's been that way ever since.

- 84,970
- 20
- 145
- 172
-
1I wouldn’t say “using it wrong” – it was correct usage. Not very readable nor what I’d use but completely acceptable and correct. – Konrad Rudolph Oct 02 '12 at 15:23
-
-
@Dave: XHTML did, because it's basically HTML elements in XML (which is much stricter about that stuff). HTML itself has always had optional end tags for some elements (and others where it's *prohibited, cause the element's defined as empty), and even optional start tags for a few. – cHao Oct 02 '12 at 15:29
-
Semantically, the usage i'm talking about (using `
` as a separator) is almost always incorrect. The very idea of an "empty paragraph" is broken, so if you're using it more than once in a row, you're using it wrong. If you're using it for the double spacing or whatever, it's wrong. `
` is a structural element, not a presentational one.
– cHao Oct 02 '12 at 16:16 -
-
@jjpcondor: What version? Cause it's been a container since at least 2.0. If you have a standard version earlier than that, i'd like to see it. – cHao Oct 02 '12 at 16:54
-
@cHao: in HTML 2.0
occurs singlely, it was a separator. http://www.hicom.net/~oedipus/wowo.html
– jjpcondor Oct 02 '12 at 17:16 -
1@jjpcondor: That page is incorrect. See http://www.w3.org/MarkUp/html-spec/html-spec_9.html -- and search for "Paragraphs". See where it says `<!ELEMENT P - O (%text)*>`? That `(%text)*` means that *paragraphs are containers*, since they can have text (and links, and line breaks, etc) inside them. The "- O" means that the start tag is required, and the end tag is optional. So `
` might be able to *look* like a separator, but it is in fact a container. And it's been that way since 2.0.
– cHao Oct 02 '12 at 17:27
There's no such thing as a separator in HTML.
<hr>
and <br>
are empty tags. They are more correctly written as . If you're using XHTML, you would use <hr/>
and <br/>
<hr/>
to indicate an empty block. However, since these elements are always empty, <hr>
is just fine in non-X HTML. But that doesn't make them 'separators'.
Older versions of HTML allowed for extremely lax in their enforcement of the rules of HTML. Browsers were designed to support sloppy HTML code which frequently included users neglecting to close elements that they had opened.
The <p>
or 'paragraph' tag was a prime example of this.
The problem with this approach is that the browser has to infer the HTML author's meaning. As pages become more advanced and JavaScript interaction with the page becomes more important, it became necessary for browser to be more stringent in their interpretation of HTML, so that JS authors could be sure that they were interacting with the resulting document model correctly.
So, in short, all that's happened is that browser don't support badly written HTML as well as they used to. All in all, that's a good thing.

- 26,597
- 10
- 74
- 130
-
2-1: “They are more correctly written as `
` and `
`” – no, that’s wrong. Self-closing tags only need the `/` in XHTML, never in HTML. – Konrad Rudolph Oct 02 '12 at 15:24 -
2"More correctly"? `
` and `
` are invalid HTML 4, and barely tolerated in HTML 5. Quit trying to bring XHTML back. :) – cHao Oct 02 '12 at 15:24 -
1@cHao They are not invalid. `/` is simply an empty attribute. And “bring XHTML back” is not entirely accurate since HTML5 can be written as XHTML (and that’s not merely “tolerated”, it’s good and valid). – Konrad Rudolph Oct 02 '12 at 15:25
-
@KonradRudolph: http://stackoverflow.com/q/3201870/319403 suggests it's a bit more than that prior to HTML 5. – cHao Oct 02 '12 at 15:27
-
1@Konrad: Also, XHTML is pretty much supported entirely because browsers already went through the work of supporting it and authors went through the trouble of using it, and they'd probably rather follow one spec than a half dozen. But it's definitely not preferred. The early versions of the spec actually specifically said, ["Generally speaking, authors are discouraged from trying to use XML on the web..."](http://www.whatwg.org/specs/web-apps/2007-10-26/multipage/section-terminology.html#html-vs). – cHao Oct 02 '12 at 15:38
-
@cHao I wonder why they removed it. ;-) But many authors (me included) *prefer* the strictness of XML over the sloppiness leading to ambiguities that are hard to diagnose. So far I’ve used the HTML variant of HTML5 but for future endeavours I’ll switch back to XHTML for precisely that reason. – Konrad Rudolph Oct 02 '12 at 15:39
-
@Konrad: It was probably removed cause when the W3C finally realized they screwed up XHTML and wanted to be relevant again, they freaked out that the HTML spec was biased against XML. Relevant or not, W3C approval customarily means a lot standardswise, so WHATWG compromised a bit. At least that's my take on it. – cHao Oct 02 '12 at 15:45
-
-
Optional end tags are an entirely supported, correct, and useful thing. It's not "extremely lax enforcement", it's *part of the spec*. The browser doesn't have to infer anything, since the meaning is already well defined. (The end tag is optional because ambiguity is not possible here. A paragraph can't contain another paragraph, per the spec, so opening a new one implicitly closes the old one, end tag or no. Any other interpretation is by definition incorrect.) – cHao Oct 02 '12 at 17:39
-
@cHao - That "Generally speaking..." sentence is pure opinion. It has no place in a specification regardless of whether it is right or wrong. – Alohci Oct 02 '12 at 18:46
-
@Alohci: Doesn't matter much to me whether it has a place or not. To me, it's evidence that the HTML 5 group barely tolerates XHTML, which was my point in the first place. :) – cHao Oct 02 '12 at 18:54
-
@cHao - There are definitely some members of WHATWG with shouty voices who really don't like it, that's very true. But there are others, more so within the W3C, who differ. Working groups are bound to have a variety of views on pretty much any matter, specs are always a compromise, and this instance is no different. What individuals think doesn't really matter. Fact is, since Microsoft implemented XHTML in IE9, XHTML is becoming an increasingly viable option for Web authors. – Alohci Oct 02 '12 at 19:42
-
@Alohci: "Viable" is *way* overstating it. For those who just want to display some content, XHTML never was and never will be worthwhile. The slightest typo can not just stop parsing, but prevent display of everything that's already been parsed. That draconian behavior is *by design* and is entirely due to XHTML's XML basis, and couldn't even be fixed even if someone wanted to. But the XHTML fans don't want to anyway -- they'd rather break all to hell than display a page incorrectly. Someone's got their priorities all screwed up. – cHao Oct 02 '12 at 20:00
-
@cHao - The "slightest typo" argument is one I've always found a little odd. I've written a lot of XML over the last dozen years or so. XSLT, XML Schemas, SOAP, SAML, SVG as well as XHTML, and it really isn't a problem. A tool like XMLSpy won't even let you save a XML file that isn't well formed unless you really insist. – Alohci Oct 02 '12 at 21:10
-
@Alohci: We don't all use IDEs or XML editors. And Notepad++ and Vim don't particularly care if your XML is off. A browser, however, will. – cHao Oct 02 '12 at 21:14
-
@cHao - Sure. What ever you do in life it helps to use the right tools. And certainly XHTML is not for everyone. But it *is* an option. – Alohci Oct 02 '12 at 21:32
` was goofy in that you could have as many opening `
` tags as you wanted, each starting a new paragraph, but only one `
` at the end. This was differrent from EVERY other html tag out there, so they fixed it to make it behave the same as all other container tags. This was also required to make the DOM tree work properly. – Marc B Oct 02 '12 at 15:20` tag, it parsed the opening tag automatically as `
`, which is in essence the same as ``. As for the answer on why W3C did this, Marc B has it spot on. – Gabi Barrientos Oct 02 '12 at 15:22` is defined as a paragraph break in this document from June 1993: http://www.w3.org/MarkUp/draft-ietf-iiir-html-01.txt
– Alohci Oct 02 '12 at 18:17` had already been changed to a container by HTML 2.0, but `