HTML5 quote that makes it clear when p
can be omitted
Since this is why most Googlers must be coming here: 4.4.1 "The p element" https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element
Tag omission in text/html:
A p element's end tag can be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
Worth noting that a few other closing tags can also be omitted, e.g. li
: https://html.spec.whatwg.org/multipage/grouping-content.html#the-li-element
The full list can be found at 12.1.2.4 "Optional tags" https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
I don't recommend doing it however as others mentioned.
This HTML "feature" is one of the reasons why HTML5 is not a subset of XML.