Home > front end >  Is it ok if a blockquote happens to be in a paragraph <p> tag?
Is it ok if a blockquote happens to be in a paragraph <p> tag?

Time:01-06

I've read Must blockquotes contain paragraphs or must paragraphs contain blockquotes?, so I see why blockquotes can contain p elements themselves. However, I feel that this, in principle, shouldn't exclude that a blockquote can happen to be in a p elements; after all, the ps inside the blockquote are the paragraphs relative to the quoted text, but why couldn't the quoted text be part of a bigger paragraph of the containing document?

See the following

<p>This is a paragraph</p>

<p> This is another paragraph: with a &lt;blockquote&gt; in it
<blockquote>some long quote</blockquote>
which (notice the lower case <i>w</i>) I write something about here, so it makes sense I'm not starting a new parapgraph, imho.
</p> <!-- this very editor highlights "p>" in red -->

CodePudding user response:

Is it ok if a blockquote happens to be in a paragraph <p> tag?

No.

The start of the blockquote element will implicitly end the p element.

This is why the end tag for the p element is shown is red: There's no matching start tag for it because the element is already closed.

p { background: yellow; }
<p>This is a paragraph</p>

<p> This is another paragraph: with a &lt;blockquote&gt; after it
<blockquote>some long quote</blockquote>
and this isn't inside a paragraph as you can tell because the CSS doesn't give it a yellow background
</p> <!-- this very editor highlights "p>" in red -->

CodePudding user response:

See the standard on how blockquote is intended. Inside a quote p are allowed but not vice versa. You could use a blockquote inside an article or section however.

Having said that. I don't believe any browser out there minds you doing whatever you like. Browsers are like that.

  •  Tags:  
  • Related