Hacker News new | ask | show | jobs
by kristopolous 1402 days ago
That's in spec for the time. HTML 2.0 draft 00, November 1994:

"2.14.1 Paragraph

         <P>

         Level 0

         The Paragraph element indicates a paragraph. The exact
         indentation, leading, etc. of a paragraph is not defined
         and may be a function of other tags, style sheets, etc.

         Typically, paragraphs are surrounded by a vertical space
         of one line or half a line. This is typically not the
         case within the Address element and or is never the case
         within the Preformatted Text element. With some HTML
         user agents, the first line in a paragraph is indented.

         Example of use:

         <H1>This Heading Precedes the Paragraph</H1>
         <P>This is the text of the first paragraph.
         <P>This is the text of the second paragraph. Although you
         do not need to start paragraphs on new lines, maintaining
         this convention facilitates document maintenance.
         <P>This is the text of a third paragraph.
"

https://datatracker.ietf.org/doc/html/draft-ietf-html-spec-0...

This is still "true". You can't embed a <P> in another <P>. It's special that way.

I've never tried it using JS with just an addChild though, I wonder what would happen...

3 comments

P is not so special, several HTML tags do not require a closing tag. I think it's even a mistake to close "br", "hr" for example?

Even the MDN docs show "hr" examples without closing: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr

Though they prefer to show "p" with closing tags (they mention it's optional though, and auto-close when one of several other tags are found: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p).

HTML was designed to be written by hand as previous generations of typesetting languages. I think this is the main difference from XML, and this was the reason of a war in the 90's about making HTML a sub-set of XML: see XHTML (https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/XHTM...)

hr makes a lot of sense not to close. Does it ever have children?

br too.

p not closing feels a bit like a MS Word pilcro. In that regard I get it.

I remember learning `<P>` this way in 1994. (And it was awhile before I saw `</LI>` end tags.)

Coincidentally, in April of this year, I got an urgent request from someone parsing 1994-era HTML, to change the ancient Racket permissive HTML parser, to support the even more ancient 1994 `p` elements better: https://www.neilvandyke.org/racket/html-parsing/#%28part._.H...

Like the optional semicolon in JS. I am a semicolon guy (and general unfan of JS tricks and shortcuts) but plenty of people prefer not to have them!