Usage of <p> inside other grouping content

Hello!

My question is mostly about coding style, I suppose.

The HTML living standard gives examples like:

<blockquote>
 <p>[Jane] then said she liked [...] fish.</p>
</blockquote>

Elements like <p>, <blockquote> and <pre> are all grouped together in a single category named grouping content.

Maybe I got it wrong but don’t they all introduce a block content (by the original definition)? Is it really necessary to wrap the content of <blockquote> in <p>? Firefox 108 seems to display it just fine and the DOM tree looks okay as well. We wouldn’t do something like

<pre>
 <p>sudo apt update</p>
</pre>

would we? The inner <p> tags appear to be superfluous. Is it a matter of preference or is there a not-so-obvious (at least to me) behavior under the hood? Does omitting them as shown below affect something?

<blockquote>[Jane] then said she liked [...] fish.</blockquote>

Hi @KBar and welcome to the community :wave:

I think it’s a matter of preference when you just have one paragraph. It’s allowed but not mandatory. With longer text content, like we usually have in an <article>, we will probably agreed that using several <p>s inside makes sense.

In the HTML living standard in the last <blockquote> example they write:

This example shows the use of a blockquote for short snippets, demonstrating that one does not have to use p elements inside blockquote elements:

<p>He began his list of "lessons" with the following:</p>
<blockquote>One should never assume that his side of
the issue will be recognized, let alone that it will
be conceded to have merits.</blockquote>
<p>He continued with a number of similar points, ending with:</p>
<blockquote>Finally, one should be prepared for the threat
of breakdown in negotiations at any given moment and not
be cowed by the possibility.</blockquote>
<p>We shall now discuss these points...

I hope that helps,
Michael

Thank you for welcoming me and providing a detailed answer!

It was late in the night and I completely missed the last paragraph! That and your explanation makes sense now.

Thanks &
Merry Christmas!

1 Like

I’m glad it was helpful.

Thanks and Happy New Year,
Michael